DGIOT是一个面向物联网的开源数据分析平台,它为用户提供了快速、高效采集、管理和分析物联网设备数据的能力,并具备多种数据处理和可视化展示方式。
DGIOT的安装实例数已经超过 35.2k,用户遍布全球。拿下多个物联网产品的领域赛道冠军。
已承建多个重大国际赛事场馆数字驾驶舱、平安校园数据中台、电信级设备监管平台、千亿级产业大脑等。
全开放源码,全流程低代码。
强大开源社区,集成和兼容各种开源工具。
商业级物联网基座,快速承接物联网项目。
面向工业物联网的轻量级开源平台,致力于平台的标准化和工具化。打造全面、丰富、专业的开源生态产品及服务。
首页 › 博客, 实战教程, 技术文章
数字工厂为针对流程制造业设计的数字化转型解决方案。
[小 迪 导读]:应用条码系统整体优势
1.条形码是迄今为止最经济、实用的一种自动识别技术。条形码技术具有以下几个方面的优点; 2.输入速度快:与键盘输入相比,条形码输入的速度是键盘输入的5倍,并且能实现“即时数据输入”; 3.可靠性高:键盘输入数据出错率为三百分之一,利用光学字符识别技术出错率为万分之一,而采用条形码技术误码率低于百万分之一; 4.灵活实用:条形码标识既可以作为一种识别手段单独使用,也可以和共它识别设备组成一个系统实现自动化识别,还可以和其他控制设备联接起来实现自动化管理。
1.生产部门在每一次报工时会生成生产单据,利用数据内部关系生成一个唯一标识编码,
get_id(DevAddr, Type) -> Time = dgiot_utils:to_binary(dgiot_datetime:timestamp()), Bin = dgiot_utils:to_binary(Type), <<ObjID:10/binary, _/binary>> = dgiot_utils:to_md5(<<Bin/binary, DevAddr/binary, Time/binary>>), Res = string:to_upper(dgiot_utils:to_list(ObjID)), dgiot_utils:to_binary(Res).
2.通过dgiot_amis下发给dgiot_dtu
{ "type": "page", "body": [ { "tabs": [ { "body": [ { "id": "u:04459a03cf7c", "api": { "url": "iotapi/amis/Device/parse_objectid", "method": "get", "adaptor": "return {\r\n \"status\":0,\r\n \"msg\":\"\",\r\n \"data\":response\r\n }", "headers": { "store": "localStorage", "dgiotReplace": "parse_objectid" } }, "body": [ { "id": "u:94629dd6e880", "api": { "url": "iotapi/classes/Device/parse_objectid", "method": "put", "headers": { "store": "localStorage", "dgiotReplace": "parse_objectid" }, "requestAdaptor": "return{\r\n ...api,\r\n data:{\r\n profile:{\r\n ...api.data\r\n }\r\n }\r\n}" }, "body": [ { "mode": "inline", "name": "data", "size": "", "type": "input-text", "label": "打印内容", "disabled": false, "readOnly": false, "horizontal": { "left": 4, "right": 8, "leftFixed": "" }, "validateApi": "", "autoComplete": false }, { "mode": "inline", "name": "cmd", "size": "", "type": "input-text", "label": "操作", "disabled": false, "readOnly": false, "horizontal": { "left": 4, "right": 8, "leftFixed": "" }, "validateApi": "", "autoComplete": false } ], "type": "form", "title": "", "submitText": "打印" } ], "type": "form", "title": "表单", "submitText": "" } ], "icon": "fa fa-slideshare", "title": "设备信息" } ], "type": "tabs" } ] }
3.dgiot_dtu通过唯一标识编码生成条形码
public static Image Get_image() { CodeLib.Barcode b = new CodeLib.Barcode(); CodeLib.TYPE type = CodeLib.TYPE.CODE128B; b.IncludeLabel = false; string familyName = "宋体"; Font Label = new Font(familyName, 10.0F); b.LabelFont = Label; CodeLib.AlignmentPositions Align = CodeLib.AlignmentPositions.CENTER; b.Alignment = Align; b.LabelPosition = CodeLib.LabelPositions.BOTTOMCENTER; return b.Encode(type, textData, 157, 80); }
4.再给默认打印机下发打印指令
public static void PrintPage(string data, string url, Dictionary<string, object> json) { SetTextData(data); SetTextUrl(url); Setjson(json); PrintDialog PD = new PrintDialog(); PageSettings pageSettings = new PageSettings(); //pageSettings.PaperSize = new PaperSize("Size", 30, 40); string Name = fPrintDocument.PrinterSettings.PrinterName; LogHelper.Log("PrinterName: " + Name.ToString()); System.Drawing.Printing.PrinterSettings Ps = new System.Drawing.Printing.PrinterSettings(); //SetDefaultPrinter("Deli DL-888B(NEW)"); fPrintDocument.DefaultPageSettings.PaperSize = new PaperSize("Size", 393, 275); //单位1/100英寸 SetDefaultPrinter(Name); PD.PrinterSettings = Ps; fPrintDocument.PrintPage += document_PrintPage; PD.Document = fPrintDocument; fPrintDocument.Print(); }
1.品检部门在检查时通过amis配置的表单按钮,向dgiot_app发起扫码请求
{ "type": "button", "api": { "url": "http://192.168.2.5:12345/scancode", "method": "get", "headers": { "Origin": "asdaszxc" }, "requestAdaptor": "console.log('请求参数',api)\r\ndelete api.headers.author\r\ndelete api.headers.email\r\nreturn {\r\n ...api\r\n}" }, "label": "扫码", "actionType": "ajax" }
2.dgiot_app收到请求,验证接口参数,下发扫码指令
public Response scancode(IHTTPSession session) { JSONObject map = new JSONObject(); JSONObject data = new JSONObject(); String Json = "{'code':200,'datetimes':'','deviceid':'1db7727cc6','instruct':'scancode','msg':'success','objectId':'1db7727cc6','username':'username'}"; ReceiveMsgBean msgBean = JSONObject.parseObject(Json, ReceiveMsgBean.class); Log.d("hallow", "Json=" + Json); Log.d("hallow", "msgBean=" + msgBean); EventBus.getDefault().post(msgBean); String text=webActivity.geturl(); data.put("scancode", text); map.put("status", 0); map.put("msg", ""); map.put("data", data); Response resp = newFixedLengthResponse(map.toJSONString()); resp.addHeader("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE, HEAD, OPTIONS, TRACE, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, MOVE, COPY, LOCK, UNLOCK"); Log.d("hallow", "map=" + map.toJSONString()); String origin=session.getHeaders().get("origin"); resp.addHeader("Access-Control-Allow-Origin", origin); resp.addHeader("Access-Control-Allow-Headers", "*"); resp.addHeader("Access-Control-Max-Age", "3600"); resp.addHeader("Access-Control-Allow-Credentials", "true"); return resp; }
3.通过人工扫码,dgiot_app再获取条码编码
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch ( resultCode ){ case 33: jsonObject = new JSONObject(); jsonObject.put("deviceid",receiveMsgBean.getDeviceid()); jsonObject.put("instruct",QR_KEY); jsonObject.put("url",data.getStringExtra("mCode")); seturl(data.getStringExtra("mCode")); DgiotService.publish( JSONObject.toJSONString( jsonObject ) ); // rdb.setInstruct(data.getStringExtra("mCode")); break; default:break; } }
4.dgiot_app通过Response响应把条码编号返回给dgiot_amis搜索框
{ "type": "input-text", "id": "u:6b51eebdf49c", "name": "scancode", "label": "扫码结果" }
5.搜索框调用get_data接口通过条码编号可迅速的把生产单据信息作为表格返回
get_all_sheet(ProductId, Start, End, Channel, DeviceId, Where, Limit, Skip, New) -> UnflattenWhere = unflatten_where(Where), case dgiot_hook:run_hook({factory, get_sheet_list}, [ProductId]) of {ok, [{ok, SheetList}]} -> SheetsData = lists:foldl( fun(X, Acc) -> SheetWhere = get_sheet_where(X, UnflattenWhere), case dgiot_factory_getdata:get_work_sheet(ProductId, X, Start, End, Channel, DeviceId, SheetWhere, undefined, undefined, New) of {ok, {_, Res}} -> Acc ++ [Res]; _ -> Acc end end, [], SheetList), IdData = get_sheet_id(SheetsData, SheetList), MergedData = merge_sheets(IdData, SheetList), %% Data = maps:values(MergedData), {Total, Res} = filter_data(Limit, Skip, MergedData), {ok, {Total, Res}}; _ -> error end.
想了解更多 dgiot 的具体细节,欢迎大家在GitHub上查看相关源代码。
加微信咨询
请填写下面表单,我们的工作人员会与您联系。
报错: 未找到这个表单
请填写下面表单,我们会即时将最新版本下载地址发到您的邮箱。
加小迪为好友即可加入交流群