plc协议开发

breach-zhy
maxw@mesnac.com 2 weeks ago
parent 9bce8c0df2
commit 66dd765033

@ -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);
}

@ -21,6 +21,26 @@ public class RemoteBusinessFallbackFactory implements FallbackFactory<RemoteBusi
public R<?> 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());
}
};
}
}

@ -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);
// }
}
}

@ -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);
}
}

Loading…
Cancel
Save