diff --git a/example/admin/init.go b/example/admin/init.go index 87d555c..f4638da 100644 --- a/example/admin/init.go +++ b/example/admin/init.go @@ -5,7 +5,7 @@ import ( . "../../../hotime/common" ) -var ID = "ea99a21b92f2b639eaaceae31dfd8499" +var ID = "7b1c0ebec5cc5b407bcd243c54d45d10" // Project 管理端项目 var Project = Proj{ diff --git a/example/app/material.go b/example/app/material.go index fe2479d..865cead 100644 --- a/example/app/material.go +++ b/example/app/material.go @@ -167,6 +167,9 @@ var materialCtr = Ctr{ } 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 diff --git a/example/app/produce.go b/example/app/produce.go index e9b6151..5b740d8 100644 --- a/example/app/produce.go +++ b/example/app/produce.go @@ -115,7 +115,73 @@ var produceCtr = Ctr{ } 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() @@ -125,10 +191,10 @@ var produceCtr = Ctr{ return } - columnStr := "produce.id,produce.sn,produce.name,produce.state" - where := Map{"state": 0, "ORDER": "modify_time DESC"} + 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", columnStr, where) + reData := that.Db.Select("produce", Map{"[>]product": "produce.product_id=product.id"}, columnStr, where) that.Display(0, reData) }, diff --git a/example/app/produce_product.go b/example/app/produce_product.go index 5cb7a73..382a8eb 100644 --- a/example/app/produce_product.go +++ b/example/app/produce_product.go @@ -3,6 +3,7 @@ package app import ( . "../../../hotime" . "../../../hotime/common" + "time" ) var produce_productCtr = Ctr{ @@ -23,18 +24,18 @@ var produce_productCtr = Ctr{ where := Map{} if id != 0 { - where["id"] = id + where["produce_product.id"] = id } else { - where["sn"] = sn + where["produce_product.sn"] = sn } re := that.Db.Get("produce_product", - Map{"[><]product": "product_spot_check.product_id=product.id", - "[><]produce": "product_spot_check.produce_id=produce.id", + Map{"[><]product": "produce_product.product_id=product.id", + "[><]produce": "produce_product.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", where) + "produce_product.id,produce_product.product_id,product.name AS product_name,produce_product.admin_id,"+ + "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, "找不到对应信息") @@ -43,4 +44,51 @@ var produce_productCtr = Ctr{ 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")) + state := ObjToInt(that.Req.FormValue("state")) + rule_check := that.Req.FormValue("rule_check") + description := that.Req.FormValue("description") + if sn == "" || rule_check == "" { + that.Display(3, "参数不足,请补充参数") + return + } + + data := Map{ + + "admin_id": adminID, + "sn": sn, + "product_id": product_id, + "produce_id": produce_id, + "create_time": time.Now().Unix(), + "modify_time": time.Now().Unix(), + } + + id := that.Db.Insert("produce_product", data) + 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) + }, } diff --git a/example/app/product.go b/example/app/product.go index 9164d43..f31726c 100644 --- a/example/app/product.go +++ b/example/app/product.go @@ -73,17 +73,35 @@ var productCtr = Ctr{ } id := ObjToInt(that.Req.FormValue("id")) - + //抽检更新 ruleSpotCheck := that.Req.FormValue("rule_spot_check") - if id == 0 || ruleSpotCheck == "" { - that.Display(3, "请求参数不足,请检查参数") - return - } + 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 + } - re := that.Db.Update("product", Map{"rule_spot_check": ruleSpotCheck, "modify_time": time.Now().Unix()}, Map{"id": id}) - if re == 0 { - that.Display(4, "更新失败,无法更新抽检参数") - return } that.Display(0, "更新成功") diff --git a/example/app/product_spot_check.go b/example/app/product_spot_check.go index 68e1904..a15ffd1 100644 --- a/example/app/product_spot_check.go +++ b/example/app/product_spot_check.go @@ -44,37 +44,39 @@ var product_spot_checkCtr = Ctr{ return } - img := that.Req.FormValue("img") - rule := that.Req.FormValue("rule") + //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")) + //count := ObjToInt(that.Req.FormValue("count")) state := ObjToInt(that.Req.FormValue("state")) - if rule == "" || produceProductId == 0 || count == 0 { + if rule == "" || produceProductId == 0 { that.Display(3, "参数不足,请补充参数") return } - if state > 0 { - count = -count - } + produceProduct := that.Db.Get("produce_product", "*", Map{"id": produceProductId}) - that.Db.Update("product", Map{"spot_check_count[#]": "spot_check_count+" + ObjToStr(count), - "spot_check_saved[#]": "spot_check_saved+" + ObjToStr(count)}, + that.Db.Update("product", Map{"spot_check_count[#]": "spot_check_count+1", + "spot_check_saved[#]": "spot_check_saved+1"}, Map{"id": produceProduct.GetCeilInt("product_id")}) - that.Db.Update("produce", Map{"spot_check_count[#]": "spot_check_count+" + ObjToStr(count), - "spot_check_saved[#]": "spot_check_saved+" + ObjToStr(count)}, + that.Db.Update("produce", Map{"spot_check_count[#]": "spot_check_count+1", + "spot_check_saved[#]": "spot_check_saved+1"}, Map{"id": produceProduct.GetCeilInt("produce_id")}) data := Map{ - "img": img, + "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, } diff --git a/example/config/app.json b/example/config/app.json index 9052e1b..5307e79 100644 --- a/example/config/app.json +++ b/example/config/app.json @@ -1,5 +1,5 @@ { - "id": "ea99a21b92f2b639eaaceae31dfd8499", + "id": "7b1c0ebec5cc5b407bcd243c54d45d10", "label": "HoTime管理平台", "menus": [ { @@ -59,6 +59,42 @@ "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" + }, { "label": "原材料管理", "table": "material" @@ -122,6 +158,42 @@ "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" + }, { "label": "生产计划", "table": "produce" @@ -189,6 +261,42 @@ "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" + }, { "label": "成品管理", "table": "product" @@ -1639,6 +1747,14 @@ "sortable": true, "type": "number", "value": "name" + }, + { + "label": "经办人", + "link": "admin", + "name": "admin_id", + "sortable": true, + "type": "number", + "value": "name" } ], "label": "生产成品", @@ -1836,6 +1952,14 @@ "sortable": true, "type": "number", "value": "name" + }, + { + "label": "抽检百分比", + "list": false, + "must": false, + "name": "spot_check_percentage", + "sortable": true, + "type": "number" } ], "label": "成品管理", @@ -1990,6 +2114,13 @@ "sortable": true, "type": "number", "value": "name" + }, + { + "label": "备注信息", + "list": false, + "must": false, + "name": "description", + "type": "text" } ], "label": "质检管理", @@ -2254,6 +2385,13 @@ "sortable": true, "type": "number", "value": "sn" + }, + { + "label": "备注信息", + "list": false, + "must": false, + "name": "description", + "type": "text" } ], "label": "抽检管理", diff --git a/example/myhs.exe b/example/myhs.exe index 1159742..cce0860 100644 Binary files a/example/myhs.exe and b/example/myhs.exe differ