鼎鼎所有售出模块的数据会统一指向到开放平台。所以,针对模块的所有操作围绕开放平台接口进行。本文档针对.NET Core后端开发人员。 > 原理 所有模块目前被记录在总部数据库的`TestMac`表,该表记录着模块和项目的映射关系。当通过项目寻找模块,通过`HeaderQuarterRepository`找到项目下的模块。 如何找到模块下的开关呢?通过开放平台接口(`api/breaker/data`)就可以。 > 开放平台:获取模块实时数据接口 请求 ``` POST http://47.103.61.198:5008/api/breaker/data Headers: Content-Type: application/json DD-Open-Key: d2ca79f1-4666-4ad5-953b-7ba5ee480fe0 Body: { "mac":"187ED53338C4" } ``` 响应: ``` { "data": { "serverinfo": { "port": "12345", "hardware": "T25", "execleakcheck": "false", "protocol_ver": "19", "mac": "187ED53338C4", "loginid": "187ED53338C4", "gate": "", "ip": "192.168.8.134", "version": "1.3.08", "loginpwd": "7a57a5a743894ae4", "ssidpwd": "2803f88db851c67a", "ssid": "DDINGW", "timezoneId": "Asia/Shanghai", "ServerProtocol": "2", "server": "47.103.61.198:5008/ebx-bishop/data/carry", "datetime": "2021-01-25 14:24:56", "leakcheckdate": "3,13,33", "lastleakcheckdate": "2017-01-01 10:00:00" }, "distributbox": { "breakers": { "1": { "version": "1.03", "title": "总路", "model": "JZK2L100-BL6523", "alarm": 0, "enableNetCtrl": true, "mxdw": 0, "mxgg": 14080, "mxgl": 96, "mxgw": 90, "mxgy": 260, "mxld": 30, "mxqy": 0, "openClose": true, "addr": 1, "power": 0, "specification": "64", "control": 1, "visibility": 1, "totalChannelId": -1, "lineType": "220", "a_A": 0, "a_T": 32.1, "a_V": 226, "a_WP": 0, "a_LD": 0.5, "a_PF": 0, "g_A": 0, "g_T": 0, "g_V": 0, "g_WP": 0, "g_LD": 0, "g_PF": 0, "b_A": 0, "b_T": 0, "b_V": 0, "b_WP": 0, "b_PF": 0, "c_A": 0, "c_T": 0, "c_V": 0, "c_WP": 0, "c_PF": 0, "n_A": 0, "n_T": 0 }, "2": { "version": "1.03", "title": "线路1", "model": "JZK2L100-BL6523", "alarm": 0, "enableNetCtrl": true, "mxdw": 0, "mxgg": 100, "mxgl": 30, "mxgw": 90, "mxgy": 260, "mxld": 30, "mxqy": 175, "openClose": true, "addr": 2, "power": 0, "specification": "20", "control": 1, "visibility": 1, "totalChannelId": 1, "lineType": "220", "a_A": 0, "a_T": 35, "a_V": 226, "a_WP": 0, "a_LD": 0, "a_PF": 0, "g_A": 0, "g_T": 0, "g_V": 0, "g_WP": 0, "g_LD": 0, "g_PF": 0, "b_A": 0, "b_T": 0, "b_V": 0, "b_WP": 0, "b_PF": 0, "c_A": 0, "c_T": 0, "c_V": 0, "c_WP": 0, "c_PF": 0, "n_A": 0, "n_T": 0 }, "3": { "version": "1.03", "title": "线路2", "model": "JZK2L100-BL6523", "alarm": 0, "enableNetCtrl": true, "mxdw": 0, "mxgg": 4400, "mxgl": 30, "mxgw": 90, "mxgy": 260, "mxld": 30, "mxqy": 175, "openClose": true, "addr": 3, "power": 0, "specification": "20", "control": 1, "visibility": 1, "totalChannelId": 1, "lineType": "220", "a_A": 0, "a_T": 35, "a_V": 226, "a_WP": 0, "a_LD": 0, "a_PF": 0, "g_A": 0, "g_T": 0, "g_V": 0, "g_WP": 0, "g_LD": 0, "g_PF": 0, "b_A": 0, "b_T": 0, "b_V": 0, "b_WP": 0, "b_PF": 0, "c_A": 0, "c_T": 0, "c_V": 0, "c_WP": 0, "c_PF": 0, "n_A": 0, "n_T": 0 } }, "change": null } }, "isError": false, "message": "success", "code": 200 } ``` 在Application层,按如下方式调用: ``` using Flurl.Http; using DD.Libs.Devices.ManDun; string url = "http://47.103.61.198:5008/api/breaker/data"; var dto = new SomeClass{ mac="187ED53338C4"}; var response = await url .WithHeader("Content-Type", "application/json") .WithHeader("DD-Open-Key", "d2ca79f1-4666-4ad5-953b-7ba5ee480fe0") .PostJsonAsync(dto) .ReceiveJson(); ``` > 开放平台:合闸或分断 请求 ``` POST http://47.103.61.198:5008/api/breaker/oc Headers: Content-Type: application/json DD-Open-Key: d2ca79f1-4666-4ad5-953b-7ba5ee480fe0 Body: { "cmd":"OCSWITCH", "value1":"open", "value2":"1,2,3", "mac":"187ED53338C4", "extra":"" } ``` 在Application层,按如下方式调用: ``` using Flurl.Http; string url = "http://47.103.61.198:5008/api/breaker/oc"; var dto = new SomeClass{ cmd="",value1="",value2="",mac="",extra=""}; var response = await url .WithHeader("Content-Type", "application/json") .WithHeader("DD-Open-Key", "d2ca79f1-4666-4ad5-953b-7ba5ee480fe0") .PostJsonAsync(dto); ```