|
|
@@ -207,6 +207,8 @@ public class DeviceDataQuery {
|
|
|
* @return 模拟数据列表
|
|
|
*/
|
|
|
private List<JSONObject> generateSimulationData(Integer deviceType, List<DmpDevice> devices) {
|
|
|
+
|
|
|
+
|
|
|
List<JSONObject> simulationList = new ArrayList<>();
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
@@ -214,21 +216,25 @@ public class DeviceDataQuery {
|
|
|
final double TEMP_RANGE_MIN = 10.0;
|
|
|
final double TEMP_RANGE_MAX = 20.0;
|
|
|
final double HUMIDITY_RANGE_MIN = 40.0;
|
|
|
- final double HUMIDITY_RANGE_MAX = 85.0;
|
|
|
+ final double HUMIDITY_RANGE_MAX = 41.0;
|
|
|
final double OXYGEN_RANGE_MIN = 20.0;
|
|
|
final double OXYGEN_RANGE_MAX = 21.0;
|
|
|
- final double CO2_RANGE_MIN = 750.0;
|
|
|
- final double CO2_RANGE_MAX = 760.0;
|
|
|
+ final double CO2_RANGE_MIN = 480.0;
|
|
|
+ final double CO2_RANGE_MAX = 490.0;
|
|
|
final double VOLTAGE_RANGE_MIN = 220.0;
|
|
|
final double VOLTAGE_RANGE_MAX = 230.0;
|
|
|
final double CURRENT_RANGE_MIN = 0.0;
|
|
|
- final double CURRENT_RANGE_MAX = 50.0;
|
|
|
+ final double CURRENT_RANGE_MAX = 1.5;
|
|
|
final double POWER_RANGE_MIN = 1.0;
|
|
|
final double POWER_RANGE_MAX = 20.0;
|
|
|
final double TEMP_LINE_RANGE_MIN = 20.0;
|
|
|
final double TEMP_LINE_RANGE_MAX = 50.0;
|
|
|
- final double LEAKAGE_CURRENT_RANGE_MIN = 0.0;
|
|
|
- final double LEAKAGE_CURRENT_RANGE_MAX = 100.0;
|
|
|
+ final double LEAKAGE_CURRENT_RANGE_MIN = 50.0;
|
|
|
+ final double LEAKAGE_CURRENT_RANGE_MAX = 60.0;
|
|
|
+ final double FLOATING_RANGE_MIN = 0.0;
|
|
|
+ final double FLOATING_RANGE_MAX = 0.5;
|
|
|
+ final double FLOATING_RANGE_MIN1 = 0.0;
|
|
|
+ final double FLOATING_RANGE_MAX1 = 1.0;
|
|
|
|
|
|
for (DmpDevice device : devices) {
|
|
|
JSONObject simulationData = new JSONObject();
|
|
|
@@ -243,14 +249,20 @@ public class DeviceDataQuery {
|
|
|
switch (deviceType) {
|
|
|
// 单一温度传感器(707)
|
|
|
case 707:
|
|
|
- double temp707 = ThreadLocalRandom.current().nextDouble(TEMP_RANGE_MIN, TEMP_RANGE_MAX);
|
|
|
+ Map<String, Double> stringDoubleMap1 = WeatherFetcher.fetchWeather();
|
|
|
+ double temp707 = 0.0;
|
|
|
+ if (stringDoubleMap1.isEmpty()) {
|
|
|
+ temp707 = ThreadLocalRandom.current().nextDouble(TEMP_RANGE_MIN, TEMP_RANGE_MAX);
|
|
|
+ } else {
|
|
|
+ double floating = ThreadLocalRandom.current().nextDouble(FLOATING_RANGE_MIN, FLOATING_RANGE_MAX);
|
|
|
+ temp707 = stringDoubleMap1.get("temperature") + 0.5 + floating;
|
|
|
+ }
|
|
|
simulationData.put("wd", formatNumber(temp707, FORMAT_2_2));
|
|
|
break;
|
|
|
|
|
|
// 单一湿度传感器(708)
|
|
|
case 708:
|
|
|
- double hum708 = ThreadLocalRandom.current().nextDouble(HUMIDITY_RANGE_MIN, HUMIDITY_RANGE_MAX);
|
|
|
- simulationData.put("sd", formatNumber(hum708, FORMAT_2_2));
|
|
|
+ simulationData.put("sd", formatNumber(ThreadLocalRandom.current().nextDouble(HUMIDITY_RANGE_MIN, HUMIDITY_RANGE_MAX), FORMAT_2_2));
|
|
|
break;
|
|
|
|
|
|
// 单一氧气传感器(709)
|
|
|
@@ -282,24 +294,38 @@ public class DeviceDataQuery {
|
|
|
|
|
|
// 电气火灾(704)
|
|
|
case 704:
|
|
|
+ Map<String, Double> stringDoubleMap = WeatherFetcher.fetchWeather();
|
|
|
// A/B/C相电压:3位整数+2位小数(220.00~230.00V)
|
|
|
- simulationData.put("aVoltage", formatNumber(ThreadLocalRandom.current().nextDouble(VOLTAGE_RANGE_MIN, VOLTAGE_RANGE_MAX), FORMAT_3_2));
|
|
|
- simulationData.put("bVoltage", formatNumber(ThreadLocalRandom.current().nextDouble(VOLTAGE_RANGE_MIN, VOLTAGE_RANGE_MAX), FORMAT_3_2));
|
|
|
- simulationData.put("cVoltage", formatNumber(ThreadLocalRandom.current().nextDouble(VOLTAGE_RANGE_MIN, VOLTAGE_RANGE_MAX), FORMAT_3_2));
|
|
|
+ double aVoltage = ThreadLocalRandom.current().nextDouble(VOLTAGE_RANGE_MIN, VOLTAGE_RANGE_MAX);
|
|
|
+ simulationData.put("aVoltage", formatNumber(aVoltage, FORMAT_3_2));
|
|
|
+ double bVoltage = ThreadLocalRandom.current().nextDouble(VOLTAGE_RANGE_MIN, VOLTAGE_RANGE_MAX);
|
|
|
+ simulationData.put("bVoltage", formatNumber(bVoltage, FORMAT_3_2));
|
|
|
+ double cVoltage = ThreadLocalRandom.current().nextDouble(VOLTAGE_RANGE_MIN, VOLTAGE_RANGE_MAX);
|
|
|
+ simulationData.put("cVoltage", formatNumber(cVoltage, FORMAT_3_2));
|
|
|
|
|
|
// A/B/C相电流:3位整数+2位小数(0.00~50.00A)
|
|
|
- simulationData.put("aElectricity", formatNumber(ThreadLocalRandom.current().nextDouble(CURRENT_RANGE_MIN, CURRENT_RANGE_MAX), FORMAT_3_2));
|
|
|
- simulationData.put("bElectricity", formatNumber(ThreadLocalRandom.current().nextDouble(CURRENT_RANGE_MIN, CURRENT_RANGE_MAX), FORMAT_3_2));
|
|
|
- simulationData.put("cElectricity", formatNumber(ThreadLocalRandom.current().nextDouble(CURRENT_RANGE_MIN, CURRENT_RANGE_MAX), FORMAT_3_2));
|
|
|
+ double aElectricity = ThreadLocalRandom.current().nextDouble(CURRENT_RANGE_MIN, CURRENT_RANGE_MAX);
|
|
|
+ simulationData.put("aElectricity", formatNumber(aElectricity, FORMAT_3_2));
|
|
|
+ double bElectricity = ThreadLocalRandom.current().nextDouble(CURRENT_RANGE_MIN, CURRENT_RANGE_MAX);
|
|
|
+ simulationData.put("bElectricity", formatNumber(bElectricity, FORMAT_3_2));
|
|
|
+ double cElectricity = ThreadLocalRandom.current().nextDouble(CURRENT_RANGE_MIN, CURRENT_RANGE_MAX);
|
|
|
+ simulationData.put("cElectricity", formatNumber(cElectricity, FORMAT_3_2));
|
|
|
|
|
|
// 总功率:4位整数+2位小数(1.00~20.00)
|
|
|
- simulationData.put("totalPower", formatNumber(ThreadLocalRandom.current().nextDouble(POWER_RANGE_MIN, POWER_RANGE_MAX), FORMAT_4_2));
|
|
|
-
|
|
|
- // 线温1-4:2位整数+2位小数(20.00~50.00℃)
|
|
|
- simulationData.put("line1TEMP", formatNumber(ThreadLocalRandom.current().nextDouble(TEMP_LINE_RANGE_MIN, TEMP_LINE_RANGE_MAX), FORMAT_2_2));
|
|
|
- simulationData.put("Line2TEMP", formatNumber(ThreadLocalRandom.current().nextDouble(TEMP_LINE_RANGE_MIN, TEMP_LINE_RANGE_MAX), FORMAT_2_2));
|
|
|
- simulationData.put("Line3TEMP", formatNumber(ThreadLocalRandom.current().nextDouble(TEMP_LINE_RANGE_MIN, TEMP_LINE_RANGE_MAX), FORMAT_2_2));
|
|
|
- simulationData.put("Line4TEMP", formatNumber(ThreadLocalRandom.current().nextDouble(TEMP_LINE_RANGE_MIN, TEMP_LINE_RANGE_MAX), FORMAT_2_2));
|
|
|
+ double totalPower = (aVoltage * aElectricity + bVoltage * bElectricity + cVoltage * cElectricity) / 1000;
|
|
|
+ simulationData.put("totalPower", formatNumber(totalPower, FORMAT_4_2));
|
|
|
+
|
|
|
+ // 线温1-4:2位整数+2位小数(20.00~50.00℃)+1.0 +0.5
|
|
|
+ double lineTemp = 0.0;
|
|
|
+ if (stringDoubleMap.isEmpty()) {
|
|
|
+ lineTemp = ThreadLocalRandom.current().nextDouble(TEMP_LINE_RANGE_MIN, TEMP_LINE_RANGE_MAX);
|
|
|
+ } else {
|
|
|
+ lineTemp = stringDoubleMap.get("temperature") + 1.0;
|
|
|
+ }
|
|
|
+ simulationData.put("line1TEMP", formatNumber(lineTemp + ThreadLocalRandom.current().nextDouble(FLOATING_RANGE_MIN1, FLOATING_RANGE_MAX1), FORMAT_2_2));
|
|
|
+ simulationData.put("Line2TEMP", formatNumber(lineTemp + ThreadLocalRandom.current().nextDouble(FLOATING_RANGE_MIN1, FLOATING_RANGE_MAX1), FORMAT_2_2));
|
|
|
+ simulationData.put("Line3TEMP", formatNumber(lineTemp + ThreadLocalRandom.current().nextDouble(FLOATING_RANGE_MIN1, FLOATING_RANGE_MAX1), FORMAT_2_2));
|
|
|
+ simulationData.put("Line4TEMP", formatNumber(lineTemp + ThreadLocalRandom.current().nextDouble(FLOATING_RANGE_MIN1, FLOATING_RANGE_MAX1), FORMAT_2_2));
|
|
|
|
|
|
// 剩余电流:4位整数+2位小数(0.00~100.00mA)
|
|
|
simulationData.put("leakageCurrent", formatNumber(ThreadLocalRandom.current().nextDouble(LEAKAGE_CURRENT_RANGE_MIN, LEAKAGE_CURRENT_RANGE_MAX), FORMAT_4_2));
|