diff --git a/example/bzyy.exe b/example/bzyy.exe index 17071e3..bb7f75f 100644 Binary files a/example/bzyy.exe and b/example/bzyy.exe differ diff --git a/example/config/app.json b/example/config/app.json index 7167346..a42d7d8 100644 --- a/example/config/app.json +++ b/example/config/app.json @@ -1,5 +1,5 @@ { - "id": "61161bc80c283839d95c99900b8dbb35", + "id": "b2d3f9ad44a39168894dc01a99f48f23", "label": "HoTime管理平台", "menus": [ { @@ -23,6 +23,14 @@ "label": "生产成品", "table": "produce_product" }, + { + "label": "生产计划", + "table": "produce" + }, + { + "label": "生产计划", + "table": "produce" + }, { "label": "生产计划", "table": "produce" @@ -57,6 +65,14 @@ { "label": "角色管理", "table": "role" + }, + { + "label": "排号计划", + "table": "ctg_order_date" + }, + { + "label": "预约订单", + "table": "order" } ], "name": "sys" @@ -77,6 +93,14 @@ "label": "产线管理", "table": "product_line" }, + { + "label": "成品管理", + "table": "product" + }, + { + "label": "成品管理", + "table": "product" + }, { "label": "成品管理", "table": "product" @@ -96,12 +120,39 @@ "label": "出入库管理", "table": "material_inout" }, + { + "label": "原材料管理", + "table": "material" + }, + { + "label": "原材料管理", + "table": "material" + }, { "label": "原材料管理", "table": "material" } ], "name": "sys:material" + }, + { + "icon": "el-icon-setting", + "label": "办理事项", + "menus": [ + { + "label": "办理事项", + "table": "matter" + }, + { + "label": "办理订单", + "table": "matter_order" + }, + { + "label": "办理事项", + "table": "matter" + } + ], + "name": "sys:matter" } ], "name": "admin", @@ -359,6 +410,125 @@ "name": "index", "notUse": true, "type": "index" + }, + { + "label": "周一上午", + "name": "am1", + "sortable": true, + "type": "number" + }, + { + "label": "周二上午", + "name": "am2", + "sortable": true, + "type": "number" + }, + { + "label": "周三上午", + "name": "am3", + "sortable": true, + "type": "number" + }, + { + "label": "周四上午", + "name": "am4", + "sortable": true, + "type": "number" + }, + { + "label": "周五上午", + "name": "am5", + "sortable": true, + "type": "number" + }, + { + "label": "周一下午", + "name": "pm1", + "sortable": true, + "type": "number" + }, + { + "label": "周二下午", + "name": "pm2", + "sortable": true, + "type": "number" + }, + { + "label": "周三下午", + "name": "pm3", + "sortable": true, + "type": "number" + }, + { + "label": "周四下午", + "name": "pm4", + "sortable": true, + "type": "number" + }, + { + "label": "周五下午", + "name": "pm5", + "sortable": true, + "type": "number" + }, + { + "label": "办理地址", + "list": false, + "must": false, + "name": "address", + "type": "text" + }, + { + "label": "叫号起始号", + "name": "startnum", + "sortable": true, + "type": "number" + }, + { + "label": "办理窗口", + "name": "window", + "type": "text" + }, + { + "label": "天府通办APP端", + "must": true, + "name": "tftbapp", + "options": [ + { + "name": "未启用", + "value": "0" + }, + { + "name": "已启用", + "value": "1" + } + ], + "sortable": true, + "type": "select" + }, + { + "label": "天府通办web端", + "must": true, + "name": "tftbweb", + "options": [ + { + "name": "未启用", + "value": "0" + }, + { + "name": "已启用", + "value": "1" + } + ], + "sortable": true, + "type": "select" + }, + { + "label": "图标", + "list": false, + "must": false, + "name": "icon", + "type": "image" } ], "label": "事项管理", @@ -419,10 +589,200 @@ "name": "parent_id", "type": "tree", "value": "name" + }, + { + "label": "天府通办web端", + "must": true, + "name": "tftbweb", + "options": [ + { + "name": "未启用", + "value": "0" + }, + { + "name": "已启用", + "value": "1" + }, + { + "name": "全部", + "value": null + } + ], + "sortable": true, + "type": "select", + "value": null + }, + { + "label": "天府通办APP端", + "must": true, + "name": "tftbapp", + "options": [ + { + "name": "未启用", + "value": "0" + }, + { + "name": "已启用", + "value": "1" + }, + { + "name": "全部", + "value": null + } + ], + "sortable": true, + "type": "select", + "value": null } ], "table": "category" }, + "ctg_order_date": { + "auth": [ + "add", + "delete", + "edit", + "info" + ], + "columns": [ + { + "add": false, + "edit": false, + "label": "ID", + "must": false, + "name": "id", + "sortable": true, + "type": "number" + }, + { + "label": "名称", + "name": "name", + "type": "text" + }, + { + "add": false, + "edit": false, + "label": "创建时间", + "list": false, + "must": false, + "name": "create_time", + "type": "time" + }, + { + "add": false, + "edit": false, + "label": "变更时间", + "must": false, + "name": "modify_time", + "type": "time" + }, + { + "label": "状态", + "must": true, + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + } + ], + "type": "select" + }, + { + "label": "预约日期", + "name": "date", + "type": "time" + }, + { + "label": "排号起始数", + "name": "start_sn", + "sortable": true, + "type": "number" + }, + { + "label": "排号结束号", + "name": "max_sn", + "sortable": true, + "type": "number" + }, + { + "label": "当前排号", + "name": "now_sn", + "sortable": true, + "type": "number" + }, + { + "label": "类别", + "link": "category", + "name": "category_id", + "sortable": true, + "type": "number", + "value": "name" + } + ], + "label": "排号计划", + "search": [ + { + "label": "请输入关键词", + "name": "keyword", + "type": "search", + "value": null + }, + { + "label": "时间段", + "name": "daterange", + "type": "search", + "value": null + }, + { + "label": "排序", + "name": "sort", + "type": "search", + "value": null + }, + { + "label": "状态", + "must": true, + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, + { + "label": "类别", + "link": "category", + "name": "category_id", + "type": "tree", + "value": "name" + } + ], + "table": "ctg_order_date" + }, "furnace_temperature": { "auth": [ "add", @@ -934,6 +1294,692 @@ ], "table": "material_inout" }, + "matter": { + "auth": [ + "add", + "delete", + "edit", + "info" + ], + "columns": [ + { + "add": false, + "edit": false, + "label": "ID", + "must": false, + "name": "id", + "sortable": true, + "type": "number" + }, + { + "label": "办理地址", + "list": false, + "must": false, + "name": "address", + "type": "text" + }, + { + "label": "业务名称", + "name": "name", + "type": "text" + }, + { + "label": "排序 序号越大越排前面", + "list": false, + "must": false, + "name": "sort", + "sortable": true, + "type": "number" + }, + { + "label": "归属专区", + "link": "matter", + "must": false, + "name": "parent_id", + "sortable": true, + "type": "number", + "value": "name" + }, + { + "label": "创建人员", + "link": "admin", + "name": "admin_id", + "sortable": true, + "type": "number", + "value": "name" + }, + { + "add": false, + "edit": false, + "label": "创建时间", + "list": false, + "must": false, + "name": "create_time", + "type": "time" + }, + { + "add": false, + "edit": false, + "label": "变更时间", + "must": false, + "name": "modify_time", + "type": "time" + }, + { + "label": "状态", + "must": true, + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + } + ], + "type": "select" + }, + { + "label": "天府通办APP端", + "must": true, + "name": "tftbapp", + "options": [ + { + "name": "未启用", + "value": "0" + }, + { + "name": "已启用", + "value": "1" + } + ], + "sortable": true, + "type": "select" + }, + { + "label": "天府通办web端", + "must": true, + "name": "tftbweb", + "options": [ + { + "name": "未启用", + "value": "0" + }, + { + "name": "已启用", + "value": "1" + } + ], + "sortable": true, + "type": "select" + }, + { + "label": "图标", + "list": false, + "must": false, + "name": "icon", + "type": "image" + }, + { + "label": "关联部门", + "link": "org", + "name": "org_id", + "sortable": true, + "type": "number", + "value": "name" + }, + { + "add": false, + "edit": false, + "info": false, + "label": "索引", + "list": false, + "must": false, + "name": "index", + "notUse": true, + "type": "index" + }, + { + "label": "表单", + "must": false, + "name": "rule", + "type": "form" + } + ], + "label": "办理事项", + "search": [ + { + "label": "请输入关键词", + "name": "keyword", + "type": "search", + "value": null + }, + { + "label": "时间段", + "name": "daterange", + "type": "search", + "value": null + }, + { + "label": "排序", + "name": "sort", + "type": "search", + "value": null + }, + { + "label": "天府通办APP端", + "must": true, + "name": "tftbapp", + "options": [ + { + "name": "未启用", + "value": "0" + }, + { + "name": "已启用", + "value": "1" + }, + { + "name": "全部", + "value": null + } + ], + "sortable": true, + "type": "select", + "value": null + }, + { + "label": "天府通办web端", + "must": true, + "name": "tftbweb", + "options": [ + { + "name": "未启用", + "value": "0" + }, + { + "name": "已启用", + "value": "1" + }, + { + "name": "全部", + "value": null + } + ], + "sortable": true, + "type": "select", + "value": null + }, + { + "label": "状态", + "must": true, + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, + { + "label": "关联部门", + "link": "org", + "name": "org_id", + "type": "tree", + "value": "name" + }, + { + "label": "归属专区", + "link": "matter", + "name": "parent_id", + "type": "tree", + "value": "name" + } + ], + "table": "matter" + }, + "matter_order": { + "auth": [ + "add", + "delete", + "edit", + "info" + ], + "columns": [ + { + "add": false, + "edit": false, + "label": "ID", + "must": false, + "name": "id", + "sortable": true, + "type": "number" + }, + { + "label": "办理事项", + "name": "name", + "type": "text" + }, + { + "add": false, + "edit": false, + "label": "创建时间", + "list": false, + "must": false, + "name": "create_time", + "type": "time" + }, + { + "add": false, + "edit": false, + "label": "变更时间", + "must": false, + "name": "modify_time", + "type": "time" + }, + { + "label": "状态", + "must": true, + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + } + ], + "type": "select" + }, + { + "label": "办理用户", + "link": "user", + "name": "user_id", + "sortable": true, + "type": "number", + "value": "name" + }, + { + "label": "办结时间", + "name": "finish_time", + "type": "time" + }, + { + "label": "办理事项", + "link": "matter", + "name": "matter_id", + "sortable": true, + "type": "number", + "value": "name" + }, + { + "label": "办理状态", + "must": true, + "name": "status", + "options": [ + { + "name": "待分配", + "value": "0" + }, + { + "name": "待办结", + "value": "1" + }, + { + "name": "已办结", + "value": "2" + }, + { + "name": "已逾期", + "value": "3" + }, + { + "name": "异常", + "value": "4" + } + ], + "type": "select" + }, + { + "label": "办事员", + "link": "admin", + "name": "admin_id", + "sortable": true, + "type": "number", + "value": "name" + }, + { + "label": "表单信息", + "must": false, + "name": "rule", + "type": "form" + } + ], + "label": "办理订单", + "search": [ + { + "label": "请输入关键词", + "name": "keyword", + "type": "search", + "value": null + }, + { + "label": "时间段", + "name": "daterange", + "type": "search", + "value": null + }, + { + "label": "排序", + "name": "sort", + "type": "search", + "value": null + }, + { + "label": "办理状态", + "must": true, + "name": "status", + "options": [ + { + "name": "待分配", + "value": "0" + }, + { + "name": "待办结", + "value": "1" + }, + { + "name": "已办结", + "value": "2" + }, + { + "name": "已逾期", + "value": "3" + }, + { + "name": "异常", + "value": "4" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, + { + "label": "状态", + "must": true, + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, + { + "label": "办理事项", + "link": "matter", + "name": "matter_id", + "type": "tree", + "value": "name" + } + ], + "table": "matter_order" + }, + "order": { + "auth": [ + "add", + "delete", + "edit", + "info" + ], + "columns": [ + { + "add": false, + "edit": false, + "label": "ID", + "must": false, + "name": "id", + "sortable": true, + "type": "number" + }, + { + "label": "预约时间", + "name": "name", + "type": "text" + }, + { + "add": false, + "edit": false, + "label": "创建时间", + "list": false, + "must": false, + "name": "create_time", + "type": "time" + }, + { + "add": false, + "edit": false, + "label": "变更时间", + "must": false, + "name": "modify_time", + "type": "time" + }, + { + "label": "状态", + "must": true, + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + } + ], + "type": "select" + }, + { + "label": "预约用户", + "link": "user", + "name": "user_id", + "sortable": true, + "type": "number", + "value": "name" + }, + { + "label": "预约日期", + "name": "date", + "type": "time" + }, + { + "label": "排号", + "name": "sn", + "sortable": true, + "type": "number" + }, + { + "label": "预约分类", + "link": "category", + "name": "category_id", + "sortable": true, + "type": "number", + "value": "name" + }, + { + "label": "预约状态", + "must": true, + "name": "status", + "options": [ + { + "name": "待分配", + "value": "0" + }, + { + "name": "待办结", + "value": "1" + }, + { + "name": "已办结", + "value": "2" + }, + { + "name": "已逾期", + "value": "3" + }, + { + "name": "异常", + "value": "4" + } + ], + "type": "select" + }, + { + "label": "办事员", + "link": "admin", + "name": "admin_id", + "sortable": true, + "type": "number", + "value": "name" + } + ], + "label": "预约订单", + "search": [ + { + "label": "请输入关键词", + "name": "keyword", + "type": "search", + "value": null + }, + { + "label": "时间段", + "name": "daterange", + "type": "search", + "value": null + }, + { + "label": "排序", + "name": "sort", + "type": "search", + "value": null + }, + { + "label": "状态", + "must": true, + "name": "state", + "options": [ + { + "name": "已启用", + "value": "0" + }, + { + "name": "未启用", + "value": "1" + }, + { + "name": "异常", + "value": "2" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, + { + "label": "预约状态", + "must": true, + "name": "status", + "options": [ + { + "name": "待分配", + "value": "0" + }, + { + "name": "待办结", + "value": "1" + }, + { + "name": "已办结", + "value": "2" + }, + { + "name": "已逾期", + "value": "3" + }, + { + "name": "异常", + "value": "4" + }, + { + "name": "全部", + "value": null + } + ], + "type": "select", + "value": null + }, + { + "label": "预约分类", + "link": "category", + "name": "category_id", + "type": "tree", + "value": "name" + } + ], + "table": "order" + }, "org": { "auth": [ "add", @@ -1020,6 +2066,11 @@ "name": "index", "notUse": true, "type": "index" + }, + { + "label": "编号", + "name": "sn", + "type": "text" } ], "label": "部门管理", @@ -2152,6 +3203,18 @@ "must": false, "name": "modify_time", "type": "time" + }, + { + "label": "编号", + "name": "sn", + "type": "text" + }, + { + "label": "身份证号", + "list": false, + "must": false, + "name": "idcard", + "type": "text" } ], "label": "客户管理", diff --git a/example/config/config.json b/example/config/config.json index 55396a3..d8ea073 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -24,7 +24,7 @@ "db": { "mysql": { "host": "192.168.6.253", - "name": "myhs", + "name": "bzyy", "password": "dasda8454456", "port": "3306", "prefix": "", diff --git a/example/main.go b/example/main.go index 9a36ab6..b6c4143 100644 --- a/example/main.go +++ b/example/main.go @@ -2,16 +2,9 @@ package main import ( "../../hotime" - "../../hotime/common" "../dri/ddsms" - "../dri/tencent" "./app" - "encoding/base64" "fmt" - "io/ioutil" - "net" - "os" - "strings" "time" ) @@ -20,118 +13,9 @@ func main() { fmt.Println(date, date.Unix()) //fmt.Println("0123456"[1:7]) appIns := hotime.Init("config/config.json") - go runTcpServer(&appIns) //运行tcp监测,产线监测使用 //RESTfull接口适配 appIns.SetConnectListener(func(context *hotime.Context) bool { - //文件上传接口 - if len(context.RouterString) == 1 && context.RouterString[0] == "ocr" && context.Req.Method == "POST" { - - //读取网络文件 - ocr := context.Req.FormValue("ocr") - if len(ocr) < 100 { - - context.Display(3, "没有上传文件") - return false - - } - filePath := context.Config.GetString("filePath") - if filePath == "" { - filePath = "file/2006/01/02/" - } - path := time.Now().Format(filePath) - 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{"url": filePath} - //fmt.Println(re1) - data["text"] = common.ObjToMap(re) - - if data["text"] != nil { - lis := data.GetMap("text").GetMap("Response").GetSlice("TextDetections") - textList := common.Slice{} - for k, _ := range lis { - li := lis.GetMap(k).GetString("DetectedText") - if li != "" { - textList = append(textList, li) - } - } - data["text"] = textList - } - - data["qrcode"] = common.ObjToMap(re1) - if data["qrcode"] != nil { - lis := data.GetMap("qrcode").GetMap("Response").GetSlice("CodeResults") - textList := common.Slice{} - for k, _ := range lis { - li := lis.GetMap(k).GetString("Url") - if li != "" { - textList = append(textList, li) - } - } - data["qrcode"] = textList - } - - fmt.Println(data.ToJsonString()) - context.Display(0, data) - return false - } - //文件上传接口 - if len(context.RouterString) == 1 && context.RouterString[0] == "qrcode" && context.Req.Method == "POST" { - - //读取网络文件 - ocr := context.Req.FormValue("ocr") - if len(ocr) < 100 { - - context.Display(3, "没有上传文件") - 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 - } - - fi, _ := base64.StdEncoding.DecodeString(ocr) - filePath = path + common.Md5(common.ObjToStr(common.RandX(100000, 9999999))) + ".jpg" - ioutil.WriteFile(context.Config.GetString("tpt")+"/"+filePath, fi, 0666) - }() - - re1 := tencent.Qrcode(ocr) - data := common.Map{} - data["qrcode"] = common.ObjToMap(re1) - if data["qrcode"] != nil { - lis := data.GetMap("qrcode").GetMap("Response").GetSlice("CodeResults") - textList := common.Slice{} - for k, _ := range lis { - li := lis.GetMap(k).GetString("Url") - if li != "" { - textList = append(textList, li) - } - } - data["qrcode"] = textList - } - - fmt.Println(data.ToJsonString()) - context.Display(0, data) - return false - } return true }) @@ -145,99 +29,3 @@ func main() { "app": app.Project, }) } -func Process(conn net.Conn, appIns *hotime.Application) { - // 循环接收客户端发送的数据 - client := conn.RemoteAddr().String() // 客户端IP:port - client = client[:strings.Index(client, ":")] - defer conn.Close() // 关闭conn - for { - // 创建一个新的切片 - buf := make([]byte, 1024) - // fmt.Printf("服务器在等待客户端%s发送信息\n", conn.RemoteAddr().String()) - n, err := conn.Read(buf) // 从conn中读取 - // 等待客户端通过conn发送信息, - // 如果客户端没有发送(write),就会阻塞在这里 - if err != nil { - // 一般为这个err - fmt.Printf("客户端%s已退出..\n", client) - return - } - // 显示客户端发送的内容到服务器的终端 - sn := string(buf[:n]) - sn = strings.Replace(sn, "\r", "", -1) - fmt.Println(client, sn) // 读到了n个数据 - - if len(sn) < 3 { - //that.Display(3, "参数不足,请补充参数") - fmt.Println(client, sn, "参数过短") // 读到了n个数据 - continue - } - - vs := appIns.Db.Select("produce", "sn,id,product_id", - common.Map{"AND": common.Map{"produce.sn[~]": sn[:len(sn)/2+1], "state[!]": 0}}) - produce := common.Map{"ld": 10000} - for _, v := range vs { - ld := common.StrLd(v.GetString("sn"), sn, true) - if ld < produce.GetCeilInt("ld") { - v["ld"] = ld - produce = v - } - } - - oldSn := appIns.Db.Get("produce_product", "id", common.Map{"AND": common.Map{"sn": sn, "produce_id": produce.GetCeilInt("id")}}) - if oldSn != nil { - fmt.Println(client, sn, "已经添加请勿重复添加") // 读到了n个数据 - continue - - } - - data := common.Map{ - "sn": sn, - "product_id": produce.GetCeilInt("product_id"), - "produce_id": produce.GetCeilInt("id"), - "create_time": time.Now().Unix(), - "modify_time": time.Now().Unix(), - } - - productLine := appIns.Db.Get("product_line", "id", common.Map{"ipaddr": client}) - - if productLine != nil { - data["product_line_id"] = productLine.GetCeilInt("id") - } - - id := appIns.Db.Insert("produce_product", data) - if id == 0 { - //that.Display(4, "添加新成品失败,请重新添加") - fmt.Println(client, sn, "添加新成品失败,请重新添加") // 读到了n个数据 - continue - } - - appIns.Db.Update("product", common.Map{"count[#]": "`count`+1"}, common.Map{"id": produce.GetCeilInt("product_id")}) - appIns.Db.Update("produce", common.Map{"now[#]": "`now`+1"}, common.Map{"id": produce.GetCeilInt("id")}) - } -} - -func runTcpServer(appIns *hotime.Application) { - - listen, err := net.Listen("tcp", "0.0.0.0:10000") - if err != nil { - fmt.Println("listen err =", err) - return - } - defer listen.Close() // 延时关闭listen - fmt.Println("listening success:", listen.Addr()) - - // 循环等待客户端来连接 - fmt.Println("等待客户端来连接..") - for { - conn, err := listen.Accept() - if err != nil { - fmt.Println("Accept() err =", err) - } else { - fmt.Printf("客户端%s已连接..\n", conn.RemoteAddr().String()) - } - // 准备一个协程,为客户端服务 - go Process(conn, appIns) - } - -}