forked from golang/hotime
出入库完成
This commit is contained in:
parent
94ae568526
commit
7a649fd652
@ -5,7 +5,7 @@ import (
|
||||
. "../../../hotime/common"
|
||||
)
|
||||
|
||||
var ID = "34c88440ab840823226a8b5f6ccfc1f9"
|
||||
var ID = "ea99a21b92f2b639eaaceae31dfd8499"
|
||||
|
||||
// Project 管理端项目
|
||||
var Project = Proj{
|
||||
|
@ -15,6 +15,7 @@ var Project = Proj{
|
||||
"material": materialCtr,
|
||||
"material_inout": material_inoutCtr,
|
||||
"produce_product": produce_productCtr,
|
||||
"produce": produceCtr,
|
||||
}
|
||||
|
||||
//生成随机码的4位随机数
|
||||
|
@ -50,8 +50,11 @@ var materialCtr = Ctr{
|
||||
|
||||
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
|
||||
@ -65,6 +68,10 @@ var materialCtr = Ctr{
|
||||
"count": 0,
|
||||
"used": 0,
|
||||
"saved": 0,
|
||||
"num": num,
|
||||
"validity": validity,
|
||||
"description": description,
|
||||
"content": content,
|
||||
"create_time": time.Now().Unix(),
|
||||
"modify_time": time.Now().Unix(),
|
||||
}
|
||||
@ -110,7 +117,70 @@ var materialCtr = Ctr{
|
||||
|
||||
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 := 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 {
|
||||
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()
|
||||
|
||||
|
@ -44,12 +44,17 @@ var material_inoutCtr = Ctr{
|
||||
rule := that.Req.FormValue("rule")
|
||||
materialId := ObjToInt(that.Req.FormValue("material_id"))
|
||||
produceId := ObjToInt(that.Req.FormValue("produce_id"))
|
||||
count := ObjToInt(that.Req.FormValue("count"))
|
||||
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
|
||||
}
|
||||
@ -61,15 +66,17 @@ var material_inoutCtr = Ctr{
|
||||
"rule": rule,
|
||||
"admin_id": adminID,
|
||||
"material_id": materialId,
|
||||
"count": count,
|
||||
"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
|
||||
|
135
example/app/produce.go
Normal file
135
example/app/produce.go
Normal file
@ -0,0 +1,135 @@
|
||||
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, "删除成功")
|
||||
},
|
||||
|
||||
"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"
|
||||
where := Map{"state": 0, "ORDER": "modify_time DESC"}
|
||||
|
||||
reData := that.Db.Select("produce", columnStr, where)
|
||||
|
||||
that.Display(0, reData)
|
||||
},
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"id": "34c88440ab840823226a8b5f6ccfc1f9",
|
||||
"id": "ea99a21b92f2b639eaaceae31dfd8499",
|
||||
"label": "HoTime管理平台",
|
||||
"menus": [
|
||||
{
|
||||
@ -27,6 +27,38 @@
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
},
|
||||
{
|
||||
"label": "原材料管理",
|
||||
"table": "material"
|
||||
@ -58,6 +90,38 @@
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
},
|
||||
{
|
||||
"label": "生产计划",
|
||||
"table": "produce"
|
||||
@ -93,6 +157,38 @@
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
},
|
||||
{
|
||||
"label": "成品管理",
|
||||
"table": "product"
|
||||
@ -687,6 +783,51 @@
|
||||
"label": "参数1",
|
||||
"name": "rule",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"label": "有效期",
|
||||
"must": true,
|
||||
"name": "validity",
|
||||
"options": [
|
||||
{
|
||||
"name": "半年",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"name": "一年",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"name": "两年",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"name": "三年",
|
||||
"value": "3"
|
||||
}
|
||||
],
|
||||
"sortable": true,
|
||||
"type": "select"
|
||||
},
|
||||
{
|
||||
"label": "识别数据",
|
||||
"list": false,
|
||||
"must": false,
|
||||
"name": "content",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"label": "备注信息",
|
||||
"list": false,
|
||||
"must": false,
|
||||
"name": "description",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"label": "默认添加数量",
|
||||
"name": "num",
|
||||
"sortable": true,
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"label": "原材料管理",
|
||||
@ -734,6 +875,36 @@
|
||||
],
|
||||
"type": "select",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"label": "有效期",
|
||||
"must": true,
|
||||
"name": "validity",
|
||||
"options": [
|
||||
{
|
||||
"name": "半年",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"name": "一年",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"name": "两年",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"name": "三年",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"name": "全部",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"sortable": true,
|
||||
"type": "select",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"table": "material"
|
||||
@ -845,6 +1016,20 @@
|
||||
"sortable": true,
|
||||
"type": "number",
|
||||
"value": "name"
|
||||
},
|
||||
{
|
||||
"label": "识别信息",
|
||||
"list": false,
|
||||
"must": false,
|
||||
"name": "content",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"label": "备注信息",
|
||||
"list": false,
|
||||
"must": false,
|
||||
"name": "description",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"label": "出入库管理",
|
||||
|
@ -50,27 +50,24 @@ func main() {
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
go func() {
|
||||
filePath := context.Config.GetString("filePath")
|
||||
if filePath == "" {
|
||||
filePath = "file/2006/01/02/"
|
||||
}
|
||||
path := time.Now().Format(filePath)
|
||||
e := os.MkdirAll(context.Config.GetString("tpt")+"/"+path, os.ModeDir)
|
||||
if e != nil {
|
||||
return
|
||||
}
|
||||
os.MkdirAll(context.Config.GetString("tpt")+"/"+path, os.ModeDir)
|
||||
|
||||
fi, _ := base64.StdEncoding.DecodeString(ocr)
|
||||
filePath = path + common.Md5(common.ObjToStr(common.RandX(100000, 9999999))) + ".jpg"
|
||||
go func() {
|
||||
|
||||
ioutil.WriteFile(context.Config.GetString("tpt")+"/"+filePath, fi, 0666)
|
||||
}()
|
||||
|
||||
re := tencent.OCR(ocr)
|
||||
|
||||
re1 := tencent.Qrcode(ocr)
|
||||
data := common.Map{}
|
||||
data := common.Map{"url": filePath}
|
||||
//fmt.Println(re1)
|
||||
data["text"] = common.ObjToMap(re)
|
||||
|
||||
|
BIN
example/myhs.exe
BIN
example/myhs.exe
Binary file not shown.
Loading…
Reference in New Issue
Block a user