更新研发

This commit is contained in:
hoteas 2022-01-22 16:12:02 +08:00
parent 3ee64fcd8c
commit 789b0a14d1
16 changed files with 463 additions and 1357 deletions

View File

@ -135,6 +135,11 @@ func ObjToFloat64(obj interface{}, e ...*Error) float64 {
err = errors.New("没有合适的转换对象!")
}
}
if math.IsNaN(v) {
err = errors.New("float64 is NaN")
v = 0
}
if len(e) != 0 {
e[0].SetError(err)
}

View File

@ -142,14 +142,14 @@ var CompanyInOutCtr = Ctr{
799, //航空航天
481, //生物医药
990, //绿色能源
799, //机械制造
972, //机械制造
1021, //建材制造
717, //化工类
170, //轻工类
260, //纺织类
1088, //商贸类
1424, //投资管理
799, //配套类
903, //配套类
959, //其他
}
totalAnalyse := this.Db.Get("org_analyse", "*", Map{"org_id": 3})
@ -157,7 +157,7 @@ var CompanyInOutCtr = Ctr{
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) + ","})
"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(),
@ -217,6 +217,7 @@ func ctgAnalyse(datas []Map, totalAnalyse Map) Map {
"拥有职业健康体系数": "暂无",
"属于本区重点企业配套数": "无",
"宿舍总面积": "无",
}
for _, v := range datas {
@ -312,7 +313,7 @@ func ctgAnalyse(datas []Map, totalAnalyse Map) Map {
resTotal["拥有质量管理体系数"] = resTotal.GetInt("拥有质量管理体系数") + 1
}
if upload_data.GetString("IEDCSJ1HZDQY、QSXZDQY") != "" && upload_data.GetString("IEDCSJ1HZDQY、QSXZDQY") != "" {
if upload_data.GetString("IEDCSJ1HZDQY、QSXZDQY") != "" && upload_data.GetString("IEDCSJ1HZDQY、QSXZDQY") != "" {
resTotal["区域100户重点企业数"] = resTotal.GetInt("区域100户重点企业数") + 1
}
@ -336,6 +337,9 @@ func ctgAnalyse(datas []Map, totalAnalyse Map) Map {
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] = "暂无"
@ -381,6 +385,7 @@ func totalAnalyse(datas []Map) (Map, Map, Map, Map) {
"拥有职业健康体系数": "暂无",
"属于本区重点企业配套数": "无",
"宿舍总面积": "无",
}
sixItem := Map{} //6
@ -502,7 +507,7 @@ func totalAnalyse(datas []Map) (Map, Map, Map, Map) {
resTotal["拥有质量管理体系数"] = resTotal.GetInt("拥有质量管理体系数") + 1
}
if upload_data.GetString("IEDCSJ1HZDQY、QSXZDQY") != "" && upload_data.GetString("IEDCSJ1HZDQY、QSXZDQY") != "" {
if upload_data.GetString("IEDCSJ1HZDQY、QSXZDQY") != "" && upload_data.GetString("IEDCSJ1HZDQY、QSXZDQY") != "" {
resTotal["区域100户重点企业数"] = resTotal.GetInt("区域100户重点企业数") + 1
}
@ -510,7 +515,7 @@ func totalAnalyse(datas []Map) (Map, Map, Map, Map) {
resTotal["符合本区重点发展产业数"] = resTotal.GetInt("符合本区重点发展产业数") + 1
}
if upload_data.GetString("IEDCFHDQZDCY") != "" && upload_data.GetString("IEDCFHDQZDCY") != "否" {
if upload_data.GetString("IEDCJBZJTXHJJTJ") != "" && upload_data.GetString("IEDCJBZJTXHJJTJ") != "否" {
resTotal["属于本区重点企业配套数"] = resTotal.GetInt("属于本区重点企业配套数") + 1
}
resTotal["企业社保人数"] = resTotal.GetFloat64("企业社保人数") + upload_data.GetFloat64("IEDCSBRS")

177
example/admin/test.go Normal file
View File

@ -0,0 +1,177 @@
package admin
import (
. "../../../hotime"
. "../../common"
"../../dri/baidu"
"fmt"
"github.com/xuri/excelize"
"io/ioutil"
"os"
"strings"
"time"
)
var TestCtr = Ctr{
"test": func(this *Context) {
data := excel1()
this.Display(0, data)
},
"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
//}
data1, _ := baidu.DefaultBaiDuMap.GetPosition("简阳市东溪镇奎星路28号")
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)
}
}

View File

@ -1,53 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
)
var adminCtr = Ctr{
"token": func(this *Context) {
this.Display(0, this.SessionId)
},
"test": func(this *Context) {
this.Session("id", this.SessionId)
},
//自带的登录
"login": func(this *Context) {
name := this.Req.FormValue("name")
pwd := this.Req.FormValue("password")
if len(name) < 2 ||
len(pwd) < 3 {
this.Display(3, "数据校验不通过")
}
where := Map{"password": Md5(pwd)}
if len(name) == 11 {
where["phone"] = name
} else {
where["name"] = name
}
admin := this.Db.Get("admin", "*", Map{"AND": where})
if admin == nil {
this.Display(4, "账户密码错误")
return
}
this.Session("id", admin.GetCeilInt("id"))
admin["password"] = nil
this.Display(0, admin)
},
"info": func(this *Context) {
admin := this.Db.Get("admin", "*", Map{"id": this.Session("id").ToInt()})
if admin == nil {
this.Display(2, "登录失效,请重新登录")
return
}
admin["password"] = nil
this.Display(0, admin)
},
}

152
example/app/analyse.go Normal file
View File

@ -0,0 +1,152 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
)
var analyseCtr = Ctr{
"home_data": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
if orgId == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("org_analyse", "*", Map{"org_id": orgId})
if res == nil {
this.Display(4, "找不到该数据")
return
}
res["home_data"] = res.GetMap("home_data")
res["six_item_data"] = res.GetMap("six_item_data")
res["three_item_data"] = res.GetMap("three_item_data")
res["n_item_data"] = res.GetMap("n_item_data")
this.Display(0, res)
},
"ctg": func(this *Context) {
orgId := ObjToInt(this.Req.FormValue("org_id"))
ctgID := ObjToInt(this.Req.FormValue("ctg_id"))
if orgId == 0 || ctgID == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("category_analyse", "*", Map{"AND": Map{"org_id": orgId, "category_id": ctgID}})
if res == nil {
this.Display(4, "找不到该数据")
return
}
res["data"] = res.GetMap("data")
res1 := this.Db.Get("org_analyse", "home_data", Map{"org_id": orgId})
res["home"] = res1.GetMap("home_data")
this.Display(0, res)
},
"map": func(this *Context) {
page := ObjToInt(this.Req.FormValue("page"))
pageSize := ObjToInt(this.Req.FormValue("pageSize"))
search := this.Req.FormValue("search")
where := Map{}
levelStr := this.Req.FormValue("level")
if levelStr != "" {
where["level"] = ObjToInt(levelStr)
}
if search != "" {
where["name[~]"] = search
}
if len(where) > 1 {
where = Map{"AND": where}
}
if page == 0 {
page = 1
}
if pageSize == 0 {
pageSize = 10
}
count := this.Db.Count("company", where)
res := this.Db.Page(page, pageSize).PageSelect("company", Map{"[><]category": "company.category_id=category.id"},
"company.id,company.name,company.level,company.address,company.score,company.lat,company.lng,company.category_id,category.name AS category_name",
where)
this.Display(0, Map{"count": count, "pageSize": pageSize, "data": res})
},
"updateCompany": func(this *Context) {
lng := ObjToFloat64(this.Req.FormValue("lng"))
lat := ObjToFloat64(this.Req.FormValue("lat"))
id := ObjToInt(this.Req.FormValue("id"))
if lng == 0 || lat == 0 || id == 0 {
this.Display(3, "请求异常")
return
}
re := this.Db.Update("company", Map{"lng": lng, "lat": lat}, Map{"id": id})
if re == 0 {
this.Display(4, "更新失败")
return
}
this.Display(0, "更新成功")
},
"companys": func(this *Context) {
page := ObjToInt(this.Req.FormValue("page"))
pageSize := ObjToInt(this.Req.FormValue("pageSize"))
search := this.Req.FormValue("search")
where := Map{}
levelStr := this.Req.FormValue("level")
if levelStr != "" {
where["level"] = ObjToInt(levelStr)
}
if search != "" {
where["name[~]"] = search
}
if len(where) > 1 {
where = Map{"AND": where}
}
where["ORDER"] = "score DESC"
if page == 0 {
page = 1
}
if pageSize == 0 {
pageSize = 10
}
count := this.Db.Count("company", where)
res := this.Db.Page(page, pageSize).PageSelect("company",
"id,name,level,score,analyse->'$.MJSR' AS MJSR,analyse->'$.MJSS' AS MJSS,analyse->'$.RJSR' AS RJSR,analyse->'$.YFJFTRQD' AS YFJFTRQD,analyse->'$.DWNHSS' AS DWNHSS,analyse->'$.ZYWRWSS' AS ZYWRWSS,analyse->'$.FZZLZBZDF' AS FZZLZBZDF,analyse->'$.LSAQZBDF' AS LSAQZBDF,analyse->'$.XZFZZBDF' AS XZFZZBDF,analyse->'$.CYRCDF' AS CYRCDF,analyse->'$.ZJTXQLDF' AS ZJTXQLDF,analyse->'$.JGTZDF' AS JGTZDF",
where)
this.Display(0, Map{"count": count, "pageSize": pageSize, "data": res})
},
"company": func(this *Context) {
id := ObjToInt(this.Req.FormValue("id"))
if id == 0 {
this.Display(3, "参数错误")
return
}
res := this.Db.Get("company", "*", Map{"id": id})
if res == nil {
this.Display(4, "找不到该数据")
return
}
analyse := res.GetMap("analyse")
if analyse != nil {
for k, v := range analyse {
if ADataType[k] != nil {
analyse[ADataType.GetString(k)] = v
}
}
res["analyse"] = analyse
}
res["upload_data"] = res.GetMap("upload_data")
res["collect_data"] = res.GetMap("collect_data")
this.Display(0, res)
},
}

View File

@ -8,15 +8,7 @@ import (
// Project 管理端项目
var Project = Proj{
//"user": UserCtr,
"product_spot_check": product_spot_checkCtr,
"product": productCtr,
"admin": adminCtr,
"sms": Sms,
"material": materialCtr,
"material_inout": material_inoutCtr,
"produce_product": produce_productCtr,
"produce": produceCtr,
"product_line": product_lineCtr,
"analyse": analyseCtr,
}
//生成随机码的4位随机数

View File

@ -1,213 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"strings"
"time"
)
var materialCtr = Ctr{
"info": func(that *Context) {
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
str, inData := that.MakeCode.Info(that.RouterString[1], data, that.Db)
where := Map{"id": that.RouterString[2]}
if len(inData) == 1 {
inData["id"] = where["id"]
where = Map{"AND": inData}
} else if len(inData) > 1 {
where["OR"] = inData
where = Map{"AND": where}
}
re := that.Db.Get(that.RouterString[1], str, where)
if re == nil {
that.Display(4, "找不到对应信息")
return
}
for k, v := range re {
column := that.MakeCode.TableColumns[that.RouterString[1]][k]
if column == nil {
continue
}
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
}
}
that.Display(0, re)
},
"add": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
name := that.Req.FormValue("name")
img := that.Req.FormValue("img")
validity := ObjToInt(that.Req.FormValue("validity"))
num := ObjToInt(that.Req.FormValue("num"))
rule := that.Req.FormValue("rule")
content := that.Req.FormValue("content")
description := that.Req.FormValue("description")
if name == "" || rule == "" {
that.Display(3, "参数不足,请补充参数")
return
}
data := Map{
"name": name,
"img": img,
"rule": rule,
"admin_id": adminID,
"count": 0,
"used": 0,
"saved": 0,
"num": num,
"validity": validity,
"description": description,
"content": content,
"create_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
}
id := that.Db.Insert("material", data)
if id == 0 {
that.Display(4, "添加材料失败,请重新添加")
return
}
data["id"] = id
that.Display(0, data)
},
"update": func(that *Context) {
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "没有找到要更新的数据")
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
childNodes := that.Db.Select(that.RouterString[1], "id,`index`", Map{"index[~]": "," + that.RouterString[2] + ","})
for _, v := range childNodes {
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
}
}
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
if re == 0 {
that.Display(4, "更新数据失败")
return
}
that.Display(0, re)
},
"inout": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
data := ObjToMap(that.Req.FormValue("data"))
texts := data.GetSlice("text")
textData := []Map{}
for k, _ := range texts {
v := texts.GetString(k)
if len(v) < 4 {
continue
}
vs := that.Db.Select("material", "name,id,content,rule,num", Map{"content[~]": v[:len(v)/2]})
for _, v1 := range vs {
if len(textData) == 0 {
textData = append(textData, v1)
}
for _, vt := range textData {
if v1.GetString("id") != vt.GetString("id") {
add := true
for _, vt1 := range textData {
if vt1.GetCeilInt("id") == v1.GetCeilInt("id") {
add = false
break
}
}
if add {
v1["count"] = 1
textData = append(textData, v1)
}
} else {
vt["count"] = vt.GetCeilInt("count") + 1
}
}
}
}
qrcode := data.GetSlice("qrcode")
for k, _ := range qrcode {
v := qrcode.GetString(k)
if len(v) < 4 {
continue
}
vs := that.Db.Select("material", "name,id,content,rule,num", Map{"content[~]": v[:len(v)/2]})
for _, v1 := range vs {
if len(textData) == 0 {
textData = append(textData, v1)
}
for _, vt := range textData {
if v1.GetString("id") != vt.GetString("id") {
v1["count"] = 1
textData = append(textData, v1)
} else {
vt["count"] = vt.GetCeilInt("count") + 1
}
}
}
}
that.Display(0, textData)
},
"search": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 10
}
leftJoin := Map{"[><]admin": "material.admin_id=admin.id"}
columnStr := "material.id,material.name,material.img,material.count,material.used,material.saved,material.admin_id,admin.name AS admin_name,material.modify_time,material.state"
where := Map{"ORDER": "modify_time DESC"}
count := that.Db.Count("material", where)
reData := that.Db.Page(page, pageSize).
PageSelect("material", leftJoin, columnStr, where)
that.Display(0, Map{"count": count, "data": reData})
},
}

View File

@ -1,188 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"strings"
"time"
)
var material_inoutCtr = Ctr{
"info": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
id := ObjToInt(that.Req.FormValue("id"))
if id == 0 {
that.Display(3, "请求参数不足,请检查参数")
return
}
re := that.Db.Get("material_inout", "*", Map{"id": id})
if re == nil {
that.Display(4, "找不到对应信息")
return
}
that.Display(0, re)
},
"add": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
img := that.Req.FormValue("img")
rule := that.Req.FormValue("rule")
materialId := ObjToInt(that.Req.FormValue("material_id"))
produceId := ObjToInt(that.Req.FormValue("produce_id"))
count := ObjToInt(that.Req.FormValue("num"))
state := ObjToInt(that.Req.FormValue("state"))
content := that.Req.FormValue("content")
description := that.Req.FormValue("description")
if rule == "" || materialId == 0 || count == 0 {
that.Display(3, "参数不足,请补充参数")
return
}
count1 := count
if state > 0 {
count = -count
}
produce_material := that.Db.Get("produce_material", "id", Map{"AND": Map{"produce_id": produceId, "material_id": materialId}})
if produce_material == nil {
that.Db.Insert("produce_material", Map{"produce_id": produceId,
"create_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
"admin_id": adminID,
"material_id": materialId})
}
if state == 0 {
that.Db.Update("material", Map{"count[#]": "count+" + ObjToStr(count), "saved[#]": "saved+" + ObjToStr(count)}, Map{"id": materialId})
} else {
that.Db.Update("material", Map{"count[#]": "count" + ObjToStr(count), "used[#]": "used+" + ObjToStr(-count)}, Map{"id": materialId})
}
material := that.Db.Get("material", "*", Map{"id": materialId})
data := Map{
"img": img,
"rule": rule,
"admin_id": adminID,
"material_id": materialId,
"count": count1,
"saved": material.GetCeilInt("count"),
"create_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
"produce_id": produceId,
"description": description,
"content": content,
"state": state,
}
id := that.Db.Insert("material_inout", data)
if id == 0 {
that.Display(4, "添加出入库记录失败,请重新添加")
return
}
data["id"] = id
that.Display(0, data)
},
"update": func(that *Context) {
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "没有找到要更新的数据")
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
childNodes := that.Db.Select(that.RouterString[1], "id,`index`", Map{"index[~]": "," + that.RouterString[2] + ","})
for _, v := range childNodes {
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
}
}
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
if re == 0 {
that.Display(4, "更新数据失败")
return
}
that.Display(0, re)
},
"remove": func(that *Context) {
inData := that.MakeCode.Delete(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "请求参数不足")
return
}
re := int64(0)
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
re = that.Db.Delete(that.RouterString[1], Map{"index[~]": "," + that.RouterString[2] + ","})
} else {
re = that.Db.Delete(that.RouterString[1], Map{"id": that.RouterString[2]})
}
if re == 0 {
that.Display(4, "删除数据失败")
return
}
that.Display(0, "删除成功")
},
"search": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
materialId := ObjToInt(that.Req.FormValue("id"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 10
}
columnStr := "material_inout.id,material_inout.material_id,material.name,material_inout.img,material_inout.count,material_inout.saved,material_inout.admin_id,admin.name AS admin_name,material_inout.modify_time,material_inout.state"
leftJoin := Map{"[><]material": "material_inout.material_id=material.id",
"[><]admin": "material_inout.admin_id=admin.id",
}
where := Map{"ORDER": "modify_time DESC"}
if materialId != 0 {
where["material_id"] = materialId
}
count := that.Db.Count("material_inout", where)
reData := that.Db.Page(page, pageSize).
PageSelect("material_inout", leftJoin, columnStr, where)
that.Display(0, Map{"count": count, "data": reData})
},
}

View File

@ -1,201 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"strings"
)
var produceCtr = Ctr{
"info": func(that *Context) {
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
str, inData := that.MakeCode.Info(that.RouterString[1], data, that.Db)
where := Map{"id": that.RouterString[2]}
if len(inData) == 1 {
inData["id"] = where["id"]
where = Map{"AND": inData}
} else if len(inData) > 1 {
where["OR"] = inData
where = Map{"AND": where}
}
re := that.Db.Get(that.RouterString[1], str, where)
if re == nil {
that.Display(4, "找不到对应信息")
return
}
for k, v := range re {
column := that.MakeCode.TableColumns[that.RouterString[1]][k]
if column == nil {
continue
}
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
}
}
that.Display(0, re)
},
"add": func(that *Context) {
inData := that.MakeCode.Add(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "请求参数不足")
return
}
re := that.Db.Insert(that.RouterString[1], inData)
if re == 0 {
that.Display(4, "无法插入对应数据")
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = index.GetString("index") + ObjToStr(re) + ","
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
} else if inData.GetString("index") != "" {
inData["index"] = "," + ObjToStr(re) + ","
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
}
that.Display(0, re)
},
"update": func(that *Context) {
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "没有找到要更新的数据")
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
childNodes := that.Db.Select(that.RouterString[1], "id,`index`", Map{"index[~]": "," + that.RouterString[2] + ","})
for _, v := range childNodes {
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
}
}
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
if re == 0 {
that.Display(4, "更新数据失败")
return
}
that.Display(0, re)
},
"remove": func(that *Context) {
inData := that.MakeCode.Delete(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "请求参数不足")
return
}
re := int64(0)
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
re = that.Db.Delete(that.RouterString[1], Map{"index[~]": "," + that.RouterString[2] + ","})
} else {
re = that.Db.Delete(that.RouterString[1], Map{"id": that.RouterString[2]})
}
if re == 0 {
that.Display(4, "删除数据失败")
return
}
that.Display(0, "删除成功")
},
"check": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
data := ObjToMap(that.Req.FormValue("data"))
texts := data.GetSlice("text")
textData := []Map{}
for k, _ := range texts {
v := texts.GetString(k)
if len(v) < 3 {
continue
}
vs := that.Db.Select("produce", Map{"[>]product": "produce.product_id=product.id"}, "produce.name,produce.id,produce.product_id,product.name AS product_name,product.rule_check,product.rule_spot_check", Map{"produce.sn[~]": v[:len(v)/2+1]})
for _, v1 := range vs {
if len(textData) == 0 {
textData = append(textData, v1)
}
for _, vt := range textData {
if v1.GetString("id") != vt.GetString("id") {
add := true
for _, vt1 := range textData {
if vt1.GetCeilInt("id") == v1.GetCeilInt("id") {
add = false
break
}
}
if add {
v1["count"] = 1
textData = append(textData, v1)
}
} else {
vt["count"] = vt.GetCeilInt("count") + 1
}
}
}
}
qrcode := data.GetSlice("qrcode")
for k, _ := range qrcode {
v := qrcode.GetString(k)
if len(v) < 3 {
continue
}
vs := that.Db.Select("produce", Map{"[>]product": "produce.product_id=product.id"}, "produce.name,produce.id,produce.product_id,product.name AS product_name,product.rule_check,product.rule_spot_check", Map{"produce.sn[~]": v[:len(v)/2+1]})
for _, v1 := range vs {
if len(textData) == 0 {
textData = append(textData, v1)
}
for _, vt := range textData {
if v1.GetString("id") != vt.GetString("id") {
v1["count"] = 1
textData = append(textData, v1)
} else {
vt["count"] = vt.GetCeilInt("count") + 1
}
}
}
}
that.Display(0, textData)
},
"search": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
columnStr := "produce.id,produce.sn,produce.name,produce.state,produce.product_id,product.name AS product_name"
where := Map{"produce.state[!]": 0, "ORDER": "produce.modify_time DESC"}
reData := that.Db.Select("produce", Map{"[>]product": "produce.product_id=product.id"}, columnStr, where)
that.Display(0, reData)
},
}

View File

@ -1,96 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"time"
)
var produce_productCtr = Ctr{
"info": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
id := ObjToInt(that.Req.FormValue("id"))
sn := that.Req.FormValue("sn")
if id == 0 && sn == "" {
that.Display(3, "请求参数不足,请检查参数")
return
}
where := Map{}
if id != 0 {
where["produce_product.id"] = id
} else {
where["produce_product.sn"] = sn
}
re := that.Db.Get("produce_product",
Map{"[><]product": "produce_product.product_id=product.id",
"[><]produce": "produce_product.produce_id=produce.id",
},
"produce_product.id,produce_product.product_id,product.name AS product_name,"+
"produce_product.modify_time,produce_product.state,product.rule_spot_check,produce_product.produce_id,produce.name AS produce_name", where)
if re == nil {
that.Display(4, "找不到对应信息")
return
}
that.Display(0, re)
},
"add": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
sn := that.Req.FormValue("sn")
product_id := ObjToInt(that.Req.FormValue("product_id"))
produce_id := ObjToInt(that.Req.FormValue("produce_id"))
product_line_id := ObjToInt(that.Req.FormValue("product_line_id"))
//state := ObjToInt(that.Req.FormValue("state"))
//rule_check := that.Req.FormValue("rule_check")
//description := that.Req.FormValue("description")
if sn == "" {
that.Display(3, "参数不足,请补充参数")
return
}
data := Map{
"sn": sn,
"product_id": product_id,
"produce_id": produce_id,
"create_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
}
data1 := ObjToMap(data.ToJsonString())
data1["product_line_id"] = product_line_id
id := that.Db.Insert("produce_product", data1)
if id == 0 {
that.Display(4, "添加新成品失败,请重新添加")
return
}
//data["id"] = id
//data["rule"] = rule_check
//data["produce_product_id"] = id
//data["state"] = state
//data["description"] = description
//id = that.Db.Insert("product_check", data)
//if id == 0 {
// that.Display(4, "添加质检失败,请重新添加")
// return
//}
that.Display(0, data)
},
}

View File

@ -1,138 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"time"
)
var productCtr = Ctr{
"info": func(that *Context) {
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
str, inData := that.MakeCode.Info(that.RouterString[1], data, that.Db)
where := Map{"id": that.RouterString[2]}
if len(inData) == 1 {
inData["id"] = where["id"]
where = Map{"AND": inData}
} else if len(inData) > 1 {
where["OR"] = inData
where = Map{"AND": where}
}
re := that.Db.Get(that.RouterString[1], str, where)
if re == nil {
that.Display(4, "找不到对应信息")
return
}
for k, v := range re {
column := that.MakeCode.TableColumns[that.RouterString[1]][k]
if column == nil {
continue
}
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
}
}
that.Display(0, re)
},
"add": func(that *Context) {
inData := that.MakeCode.Add(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "请求参数不足")
return
}
re := that.Db.Insert(that.RouterString[1], inData)
if re == 0 {
that.Display(4, "无法插入对应数据")
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = index.GetString("index") + ObjToStr(re) + ","
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
} else if inData.GetString("index") != "" {
inData["index"] = "," + ObjToStr(re) + ","
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
}
that.Display(0, re)
},
"update": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
id := ObjToInt(that.Req.FormValue("id"))
//抽检更新
ruleSpotCheck := that.Req.FormValue("rule_spot_check")
if ruleSpotCheck != "" {
spotCheckPercentage := ObjToInt(that.Req.FormValue("spot_check_percentage"))
if id == 0 || ruleSpotCheck == "" {
that.Display(3, "请求参数不足,请检查参数")
return
}
re := that.Db.Update("product", Map{"rule_spot_check": ruleSpotCheck, "spot_check_percentage": spotCheckPercentage, "modify_time": time.Now().Unix()}, Map{"id": id})
if re == 0 {
that.Display(4, "更新失败,无法更新抽检参数")
return
}
} else {
//质检更新
ruleCheck := that.Req.FormValue("rule_check")
if id == 0 || ruleCheck == "" {
that.Display(3, "请求参数不足,请检查参数")
return
}
re := that.Db.Update("product", Map{"rule_check": ruleCheck, "modify_time": time.Now().Unix()}, Map{"id": id})
if re == 0 {
that.Display(4, "更新失败,无法更新质检参数")
return
}
}
that.Display(0, "更新成功")
},
"search": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 10
}
leftJoin := Map{"[><]admin": "product.admin_id=admin.id"}
columnStr := "product.id,product.name,product.img,product.count,product.used,product.saved,product.spot_check_count,product.admin_id,admin.name AS admin_name,product.modify_time,product.state"
where := Map{"ORDER": "modify_time DESC"}
count := that.Db.Count("product", where)
reData := that.Db.Page(page, pageSize).
PageSelect("product", leftJoin, columnStr, where)
that.Display(0, Map{"count": count, "data": reData})
},
}

View File

@ -1,146 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"strings"
)
var product_lineCtr = Ctr{
"info": func(that *Context) {
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
str, inData := that.MakeCode.Info(that.RouterString[1], data, that.Db)
where := Map{"id": that.RouterString[2]}
if len(inData) == 1 {
inData["id"] = where["id"]
where = Map{"AND": inData}
} else if len(inData) > 1 {
where["OR"] = inData
where = Map{"AND": where}
}
re := that.Db.Get(that.RouterString[1], str, where)
if re == nil {
that.Display(4, "找不到对应信息")
return
}
for k, v := range re {
column := that.MakeCode.TableColumns[that.RouterString[1]][k]
if column == nil {
continue
}
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), "id,"+column.GetString("value"), Map{"id": v})
}
}
that.Display(0, re)
},
"add": func(that *Context) {
inData := that.MakeCode.Add(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "请求参数不足")
return
}
re := that.Db.Insert(that.RouterString[1], inData)
if re == 0 {
that.Display(4, "无法插入对应数据")
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = index.GetString("index") + ObjToStr(re) + ","
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
} else if inData.GetString("index") != "" {
inData["index"] = "," + ObjToStr(re) + ","
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
}
that.Display(0, re)
},
"update": func(that *Context) {
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "没有找到要更新的数据")
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
Index := that.Db.Get(that.RouterString[1], "`index`", Map{"id": that.RouterString[2]})
parentIndex := that.Db.Get(that.RouterString[1], "`index`", Map{"id": inData.Get("parent_id")})
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
childNodes := that.Db.Select(that.RouterString[1], "id,`index`", Map{"index[~]": "," + that.RouterString[2] + ","})
for _, v := range childNodes {
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
}
}
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
if re == 0 {
that.Display(4, "更新数据失败")
return
}
that.Display(0, re)
},
"remove": func(that *Context) {
inData := that.MakeCode.Delete(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "请求参数不足")
return
}
re := int64(0)
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
re = that.Db.Delete(that.RouterString[1], Map{"index[~]": "," + that.RouterString[2] + ","})
} else {
re = that.Db.Delete(that.RouterString[1], Map{"id": that.RouterString[2]})
}
if re == 0 {
that.Display(4, "删除数据失败")
return
}
that.Display(0, "删除成功")
},
"search": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
//page := ObjToInt(that.Req.FormValue("page"))
//pageSize := ObjToInt(that.Req.FormValue("pageSize"))
//
//if page < 1 {
// page = 1
//}
//if pageSize <= 0 {
// pageSize = 10
//}
//leftJoin := Map{"[><]admin": "product.admin_id=admin.id"}
where := Map{"state": 0, "ORDER": "modify_time DESC"}
//count := that.Db.Count("product", where)
reData := that.Db.Select("product_line", "*", where)
that.Display(0, reData)
},
}

View File

@ -1,138 +0,0 @@
package app
import (
. "../../../hotime"
. "../../../hotime/common"
"time"
)
var product_spot_checkCtr = Ctr{
"info": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
id := ObjToInt(that.Req.FormValue("id"))
if id == 0 {
that.Display(3, "请求参数不足,请检查参数")
return
}
re := that.Db.Get("product_spot_check",
Map{"[><]product": "product_spot_check.product_id=product.id",
"[><]produce": "product_spot_check.produce_id=produce.id",
},
"id,img,product_id,product.name AS product_name,admin_id,"+
"modify_time,state,rule,produce_id,produce.name AS produce_name", Map{"id": id})
if re == nil {
that.Display(4, "找不到对应信息")
return
}
that.Display(0, re)
},
"add": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
//img := that.Req.FormValue("img")
sn := that.Req.FormValue("sn")
rule := that.Req.FormValue("rule_spot_check")
description := that.Req.FormValue("description")
produceProductId := ObjToInt(that.Req.FormValue("produce_product_id"))
//count := ObjToInt(that.Req.FormValue("count"))
state := ObjToInt(that.Req.FormValue("state"))
if rule == "" || produceProductId == 0 {
that.Display(3, "参数不足,请补充参数")
return
}
produceProduct := that.Db.Get("produce_product", "*", Map{"id": produceProductId})
if produceProduct == nil {
that.Display(4, "找不到成品记录,无法进行抽检")
return
}
//判断是否已经抽检了
alreadyCheck := that.Db.Get("product_spot_check", "id", Map{"produce_product_id": produceProductId})
if alreadyCheck == nil {
that.Db.Update("product", Map{"spot_check_count[#]": "spot_check_count+1"},
Map{"id": produceProduct.GetCeilInt("product_id")})
that.Db.Update("produce", Map{"spot_check_count[#]": "spot_check_count+1"},
Map{"id": produceProduct.GetCeilInt("produce_id")})
}
data := Map{
"sn": sn,
"rule": rule,
"admin_id": adminID,
"create_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
"product_id": produceProduct.GetCeilInt("product_id"),
"produce_id": produceProduct.GetCeilInt("produce_id"),
"produce_product_id": produceProductId,
"description": description,
"state": state,
}
id := that.Db.Insert("product_spot_check", data)
if id == 0 {
that.Display(4, "添加抽检记录失败,请重新添加")
return
}
data["id"] = id
that.Display(0, data)
},
"search": func(that *Context) {
adminID := that.Session("id").ToInt()
if adminID == 0 {
that.Display(2, "登录失效,请重新登录")
return
}
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
productId := ObjToInt(that.Req.FormValue("id"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 10
}
columnStr := "product_spot_check.id,product_spot_check.product_id,product_spot_check.sn,product.name,product_spot_check.img,product_spot_check.admin_id,admin.name AS admin_name,product_spot_check.modify_time,product_spot_check.state"
leftJoin := Map{"[><]product": "product_spot_check.product_id=product.id",
"[><]admin": "product_spot_check.admin_id=admin.id",
}
where := Map{"ORDER": "id DESC"}
if productId != 0 {
where["product_id"] = productId
}
count := that.Db.Count("product_spot_check", where)
reData := that.Db.Page(page, pageSize).
PageSelect("product_spot_check", leftJoin, columnStr, where)
that.Display(0, Map{"count": count, "data": reData})
},
}

View File

@ -1,33 +0,0 @@
package app
import (
. "../../../hotime"
"../../dri/ddsms"
)
var Sms = Ctr{
//只允许微信验证过的或者登录成功的发送短信
"send": func(this *Context) {
//if this.Session("uid").Data == nil && this.Session("wechatInfo").Data == nil {
// this.Display(2, "没有授权")
// return
//}
if len(this.Req.FormValue("token")) != 32 {
this.Display(2, "没有授权")
return
}
phone := this.Req.FormValue("phone")
if len(phone) < 11 {
this.Display(3, "手机号格式错误")
return
}
code := getCode()
this.Session("phone", phone)
this.Session("code", code)
ddsms.DefaultDDY.SendYZM(phone, this.Config.GetString("smsLogin"), map[string]string{"code": code})
this.Display(0, "发送成功")
},
}

116
example/app/tt.go Normal file
View File

@ -0,0 +1,116 @@
package app
import (
. "../../common"
)
var ADataType = Map{
"PJ": "评级",
"ZDF": "总得分",
"NZDF": "N项总得分",
"JGTZDF": "技改投资得分",
"JGTZ": "技改投资金额",
"ZJTXQLDF": "专精特新潜力得分",
"JBZJTXQYJCYQDF": "具备专精特新企业基础要求得分",
"JBZJTXQYYQCPDF": "具备专精特新企业要求产品得分",
"JBZJTXHJJTJDF": "具备专精特新环境及条件得分",
"JBZJTXZSCQYQDF": "具备专精特新知识产权要求得分",
"YFZBDF": "2年研发占比得分",
"KYRYZBDF": "科研人员占比得分",
"ZCFZLDF": "资产负债率得分",
"CYRCDF": "产业人才得分",
"SXZBDF": "3项指标",
"XZFZZBDF": "协作发展指标得分",
"FHDQZDCYDF": "符合地区重点产业得分",
"QYZDQYDF": "区域重点企业",
"SJ100HZDQYDF": "市级100户重点企业得分",
"CYL30HDF": "产业链30户得分",
"LSAQZBDF": "绿色安全指标",
"AQSCGLDF": "安全生产管理得分",
"QYAQSCDBDF": "企业安全生产是否达标得分",
"QYFXYHSKTXJSDF": "企业风险隐患双预控体系建设得分",
"AQSGDF": "安全事故得分",
"AQJCDF": "安全检查得分",
"LSSCGYDF": "绿色生产工艺得分",
"JPJSSJDF": "减排技术升级改造得分",
"HBJCDF": "环保检查得分",
"FZZLZBZDF": "发展质量指标总分",
"QYYLNLZDF": "企业盈利能力总得分",
"KSDF": "企业连续3年亏损得分",
"QYLRL": "企业利润率",
"DNLRZEDF": "当年利润总额得分",
"LXSNYLDF": "连续3年盈利得分",
"ZSCQDF": "知识产权总得分",
"TGMLDF": "推广目录得分",
"ZLDF": "专利得分",
"STTDF": "首台(套)、首批次、首版次企业得分",
"MJSR": "亩均收入",
"MJSRDF": "亩均收入得分",
"MJSS": "亩均税收",
"MJSSDF": "亩均税收得分",
"RJSR": "人均收入",
"RJSRDF": "人均收入得分",
"YFJFTRQD": "研发经费投入强度",
"YFJFTRQDDF": "研发经费投入强度得分",
"DWNHSS": "单位能耗税收",
"DWNHSSDF": "单位能耗税收得分",
"ZYWRWSS": "主要污染物税收",
"ZYWRWSSDF": "主要污染物税收得分",
"NXZBDF": "6项指标得分",
"DJSDLQYDF": "独角兽、瞪羚企业得分",
"JSZXDF": "企业获得技术中心得分",
"YFFYDF": "研发费用得分",
"GXJSQYDF": "高新技术企业得分",
"FZQLDF": "发展潜力总分",
}

View File

@ -2,17 +2,12 @@ package main
import (
"../../hotime"
"../common"
"io/ioutil"
//"../dri/aliyun"
"../dri/baidu"
"../dri/ddsms"
"./admin"
"./app"
"fmt"
"github.com/xuri/excelize"
"os"
"time"
)
@ -29,85 +24,7 @@ func main() {
return true
})
appIns.Router["admin"]["company_inout"] = admin.CompanyInOutCtr
appIns.Router["admin"]["test"] = hotime.Ctr{
"test": func(this *hotime.Context) {
data := excel()
this.Display(0, data)
},
"api": func(this *hotime.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
//}
data1, _ := baidu.DefaultBaiDuMap.GetPosition("简阳市东溪镇奎星路28号")
this.Display(0, common.ObjToMap(data1))
},
"temp": func(this *hotime.Context) {
count := 0
for true {
data := this.Db.Get("area_copy", "id,parent_id,`index`,parent_code", common.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`", common.Map{"area_code": data.GetString("parent_code")})
if parentData == nil {
this.Db.Update("area_copy", common.Map{"index": data.GetString("id") + ","}, common.Map{"id": data.GetString("id")})
} else {
this.Db.Update("area_copy", common.Map{"index": parentData.GetString("index") + data.GetString("id") + ",", "parent_id": parentData["id"]}, common.Map{"id": data.GetString("id")})
}
}
this.Display(0, count)
},
"tempctg": func(this *hotime.Context) {
dataBytes, e := ioutil.ReadFile("2017.json")
if e != nil {
this.Display(4, e)
return
}
data := common.ObjToSlice(string(dataBytes))
for k, _ := range data {
ins := data.GetMap(k)
ins["level"] = 1
id := this.Db.Insert("category", common.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," + common.ObjToStr(id) + ","
this.Db.Update("category", common.Map{"index": ins["index"]}, common.Map{"id": ins["id"]})
run(ins, this)
}
},
}
appIns.Router["admin"]["test"] = admin.TestCtr
//makeCode := code.MakeCode{}
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
@ -119,55 +36,3 @@ func main() {
"app": app.Project,
})
}
func excel() common.Slice {
xlsx, err := excelize.OpenFile("tpt/piduqu.xlsx")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
list := xlsx.GetSheetList()
data := common.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 common.Map, this *hotime.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", common.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") + common.ObjToStr(id) + ","
this.Db.Update("category", common.Map{"index": cins["index"]}, common.Map{"id": cins["id"]})
run(cins, this)
}
}