From 66dd7650332007ea0c5cbdbabe21d9a0817ea202 Mon Sep 17 00:00:00 2001 From: "maxw@mesnac.com" Date: Mon, 6 Jan 2025 20:31:50 +0800 Subject: [PATCH] =?UTF-8?q?plc=E5=8D=8F=E8=AE=AE=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/api/RemoteBusinessService.java | 5 ++ .../RemoteBusinessFallbackFactory.java | 20 ++++++++ .../service/impl/DataProcessServiceImpl.java | 50 +++++++++++++++---- .../main/java/com/ruoyi/job/task/RyTask.java | 15 ++++++ 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/ruoyi-api/hw-api-business/src/main/java/com/ruoyi/business/api/RemoteBusinessService.java b/ruoyi-api/hw-api-business/src/main/java/com/ruoyi/business/api/RemoteBusinessService.java index 10dfed8..030e20f 100644 --- a/ruoyi-api/hw-api-business/src/main/java/com/ruoyi/business/api/RemoteBusinessService.java +++ b/ruoyi-api/hw-api-business/src/main/java/com/ruoyi/business/api/RemoteBusinessService.java @@ -26,4 +26,9 @@ public interface RemoteBusinessService { @GetMapping("/plcDevice/mcDataProcess") public R mcDataProcess(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + @GetMapping("/plcDevice/aeDataProcess") + public R aeDataProcess(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @GetMapping("/plcDevice/ehternetDataProcess") + public R ehternetDataProcess(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); } diff --git a/ruoyi-api/hw-api-business/src/main/java/com/ruoyi/business/api/factory/RemoteBusinessFallbackFactory.java b/ruoyi-api/hw-api-business/src/main/java/com/ruoyi/business/api/factory/RemoteBusinessFallbackFactory.java index cb97dd6..268a53b 100644 --- a/ruoyi-api/hw-api-business/src/main/java/com/ruoyi/business/api/factory/RemoteBusinessFallbackFactory.java +++ b/ruoyi-api/hw-api-business/src/main/java/com/ruoyi/business/api/factory/RemoteBusinessFallbackFactory.java @@ -21,6 +21,26 @@ public class RemoteBusinessFallbackFactory implements FallbackFactory computeOnlineDevicecCount(int days, String source) { return R.fail("获取租户信息失败:" + throwable.getMessage()); } + + @Override + public R modbusDataProcess(String source) { + return R.fail("获取租户信息失败:" + throwable.getMessage()); + } + + @Override + public R mcDataProcess(String source) { + return R.fail("获取租户信息失败:" + throwable.getMessage()); + } + + @Override + public R aeDataProcess(String source) { + return R.fail("获取租户信息失败:" + throwable.getMessage()); + } + + @Override + public R ehternetDataProcess(String source) { + return R.fail("获取租户信息失败:" + throwable.getMessage()); + } }; } } diff --git a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java index 622567a..277936e 100644 --- a/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java +++ b/ruoyi-modules/hw-data-process/src/main/java/com/ruoyi/dataprocess/service/impl/DataProcessServiceImpl.java @@ -99,7 +99,8 @@ public class DataProcessServiceImpl extends CommanHandleService implements IData @Override public int processBusinessData(String jsonData, String imagePath, String imagePatterns, String imageDomain, String imagePrefix, String topic) { - JSONObject json = JSON.parseObject(jsonData); + String data = jsonData.replaceAll(" ", ""); + JSONObject json = JSON.parseObject(data); Long ts = json.getLong(TdEngineConstants.PAYLOAD_TS); String tsStr = String.valueOf(ts); if (tsStr.length() == 10) { @@ -164,7 +165,7 @@ public class DataProcessServiceImpl extends CommanHandleService implements IData } - if (value instanceof String) { + if (value instanceof String && key !="longitude" && key != "latitude") { String valueStr = (String) value; if (StringUtils.isNotBlank(valueStr)) { /** @@ -198,22 +199,49 @@ public class DataProcessServiceImpl extends CommanHandleService implements IData schemaFields.add(tdField); } } else { - TdField tdField = new TdField(); - tdField.setFieldName(key); - tdField.setFieldValue(value); - schemaFields.add(tdField); - - //经纬度判断 if (key.equalsIgnoreCase(HwDictConstants.DEFAULT_FUNCTION_LONGITUDE_IDENTIFIER)) { - longitude = value; + String value1 = value.toString(); + String value2 = value1.substring(1,value1.length()); + longitude = value2; + TdField tdField = new TdField(); + tdField.setFieldName(key); + tdField.setFieldValue(value2); + schemaFields.add(tdField); } else if (key.equalsIgnoreCase(HwDictConstants.DEFAULT_FUNCTION_LATITUDE_IDENTIFIER)) { - latitude = value; - } else { + String value1 = value.toString(); + String value2 = value1.substring(1,value1.length()); + latitude = value2; + TdField tdField = new TdField(); + tdField.setFieldName(key); + tdField.setFieldValue(value2); + schemaFields.add(tdField); + }else { TdField alarmTdField = new TdField(); alarmTdField.setFieldName(originalKey); alarmTdField.setFieldValue(value); alarmSchemaFields.add(alarmTdField); + TdField tdField = new TdField(); + tdField.setFieldName(key); + tdField.setFieldValue(value); + schemaFields.add(tdField); } + + +// //经纬度判断 +// if (key.equalsIgnoreCase(HwDictConstants.DEFAULT_FUNCTION_LONGITUDE_IDENTIFIER)) { +// String value1 = value.toString(); +// value2 = value1.substring(2); +// longitude = value2; +// } else if (key.equalsIgnoreCase(HwDictConstants.DEFAULT_FUNCTION_LATITUDE_IDENTIFIER)) { +// String value1 = value.toString(); +// value2 = value1.substring(2); +// latitude = value2; +// } else { +// TdField alarmTdField = new TdField(); +// alarmTdField.setFieldName(originalKey); +// alarmTdField.setFieldValue(value); +// alarmSchemaFields.add(alarmTdField); +// } } } diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/RyTask.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/RyTask.java index 4a16159..d4cde95 100644 --- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/RyTask.java +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/RyTask.java @@ -31,6 +31,21 @@ public class RyTask { public void computeOnlineDevicesCount(Integer days) { + System.out.println("开始了"); this.remoteBusinessService.computeOnlineDevicecCount(days, SecurityConstants.INNER); } + public void mcDataProcess() { + remoteBusinessService.mcDataProcess(SecurityConstants.INNER); + } + public void modbusDataProcess() { + remoteBusinessService.modbusDataProcess(SecurityConstants.INNER); + } + + public void aeDataProcess() { + remoteBusinessService.aeDataProcess(SecurityConstants.INNER); + } + + public void ehternetDataProcess() { + remoteBusinessService.ehternetDataProcess(SecurityConstants.INNER); + } }