| | |
| | | return "Message sent to topic " + topic; |
| | | } |
| | | |
| | | @GetMapping("/create") |
| | | public String create(@RequestParam String topic, @RequestParam String message) { |
| | | try { |
| | | iotdbCfg.getSessionPool().createTimeseries("root.f2.myt1", TSDataType.UNKNOWN, null, null); |
| | | } catch (IoTDBConnectionException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (StatementExecutionException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | return "Message sent to topic " + topic; |
| | | } |
| | | |
| | | @GetMapping("/rec2") |
| | | public void testRec2() { |
| | | //数据格式:{"174":[{"values":{"d1":12},"ts":"1721978780449"}]} 174是应用id |
| | | //多条格式:{"174":[{"values":{"DeviceStatus":2},"ts":"1722478128278"},{"values":{"spindleSpeed":22},"ts":"1722478128281"}]} |
| | | String payload = "{\"174\":[{\"values\":{\"DeviceStatus\":2,\"Output\":34},\"ts\":\"1723709061525\"}]}"; |
| | | //多条格式:{"174":[{"values":{"DeviceStatus":2},"ts":"1722478128278"},{"values":{"SpindleSpeed":22},"ts":"1722478128281"}]} |
| | | String payload = "{\"182\":[{\"values\":{\"DeviceStatus_n\":2,\"Output\":38},\"ts\":\""+System.currentTimeMillis()+"\"}]}"; |
| | | //payload = "{\"174\":[{\"values\":{\"Output\":11},\"ts\":\"1722478128278\"},{\"values\":{\"SpindleSpeed\":22},\"ts\":\"1722478128281\"}]}"; |
| | | recService.handle(payload); |
| | | } |
| | | @GetMapping("/rec") |
| | | public void testRec() { |
| | | ////数据格式:{"174":[{"values":{"d1":12},"ts":"1721978780449"}]} 174是应用id |
| | | //多条格式:{"174":[{"values":{"output":11},"ts":"1722478128278"},{"values":{"spindleSpeed":22},"ts":"1722478128281"}]} |
| | | String payload = "{\"174\":[{\"values\":{\"output\":12},\"ts\":\"1721978780449\"}]}"; |
| | | |
| | | |
| | | @GetMapping("/recalarm") |
| | | public void testAlarm() { |
| | | //数据格式:{"174":[{"values":{"d1":12},"ts":"1721978780449"}]} 174是应用id |
| | | //多条格式:{"174":[{"values":{"DeviceStatus":2},"ts":"1722478128278"},{"values":{"spindleSpeed":22},"ts":"1722478128281"}]} |
| | | |
| | | JSONObject jsonObj = JSONObject.parseObject(payload); |
| | | //数据格式:{"174":[{"values":{"d1":12},"ts":"1721978780449"}]} 174是应用id |
| | | Set<String> keys = jsonObj.keySet(); |
| | | String appId = keys.toArray(new String[] {})[0]; |
| | | JSONArray dtArr = jsonObj.getJSONArray(appId); |
| | | JSONObject data = dtArr.getJSONObject(0); |
| | | long time = data.getLong("ts"); |
| | | String output = data.getJSONObject("values").getString("output"); |
| | | //AggrgateData ad = recService.fillFactoryData(payload); |
| | | |
| | | List<String> fields = new ArrayList<>(); |
| | | List<String> values = new ArrayList<>(); |
| | | //long time = System.currentTimeMillis(); |
| | | fields.add("output"); |
| | | fields.add("factory_year"); |
| | | fields.add("factory_month"); |
| | | fields.add("factory_date");//INT64, INT64,factory_date INT64,factory_week |
| | | values.add(output); |
| | | |
| | | |
| | | //iotdbCfg.insertRecord("root.qa.myoutput_"+ad.getWorkstationId(), time, fields, values); |
| | | String payload = "{\"174\":[{\"values\":{\"Alarm\":\"告警信息1\"},\"ts\":\""+System.currentTimeMillis()+"\"}]}"; |
| | | //payload = "{\"174\":[{\"values\":{\"Output\":11},\"ts\":\"1722478128278\"},{\"values\":{\"SpindleSpeed\":22},\"ts\":\"1722478128281\"}]}"; |
| | | recService.handle(payload); |
| | | } |
| | | |
| | | @GetMapping("/tpl") |