|
@@ -2,10 +2,13 @@ package com.kym.service.awoara;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
|
|
|
+import com.google.gson.FieldNamingPolicy;
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
|
+import com.google.gson.GsonBuilder;
|
|
|
import com.kym.common.exception.BusinessException;
|
|
import com.kym.common.exception.BusinessException;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
import com.kym.common.utils.CommUtil;
|
|
|
|
|
+import com.kym.entity.DeviceConfig;
|
|
|
import com.kym.entity.awoara.ApiList;
|
|
import com.kym.entity.awoara.ApiList;
|
|
|
-import com.kym.entity.awoara.Config;
|
|
|
|
|
import com.kym.entity.awoara.MethodHelp;
|
|
import com.kym.entity.awoara.MethodHelp;
|
|
|
import com.kym.entity.awoara.OrderInfo;
|
|
import com.kym.entity.awoara.OrderInfo;
|
|
|
import com.kym.entity.awoara.response.AwoaraResponse;
|
|
import com.kym.entity.awoara.response.AwoaraResponse;
|
|
@@ -17,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.Base64;
|
|
import java.util.Base64;
|
|
|
|
|
|
|
|
import static cn.hutool.http.HttpStatus.HTTP_OK;
|
|
import static cn.hutool.http.HttpStatus.HTTP_OK;
|
|
@@ -31,6 +35,10 @@ import static cn.hutool.http.HttpStatus.HTTP_OK;
|
|
|
public class AwoaraServiceImpl implements AwoaraService {
|
|
public class AwoaraServiceImpl implements AwoaraService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ static final Gson gson = new GsonBuilder()
|
|
|
|
|
+ .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeAdapter())
|
|
|
|
|
+ .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
|
|
|
|
|
+ .create();
|
|
|
/**
|
|
/**
|
|
|
* BASE64解码器
|
|
* BASE64解码器
|
|
|
*/
|
|
*/
|
|
@@ -191,6 +199,7 @@ public class AwoaraServiceImpl implements AwoaraService {
|
|
|
""".formatted(orderId);
|
|
""".formatted(orderId);
|
|
|
doRequest(productKey, deviceName, params, null);
|
|
doRequest(productKey, deviceName, params, null);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void forceCloseOrder(String productKey, String deviceName) {
|
|
public void forceCloseOrder(String productKey, String deviceName) {
|
|
|
var params = """
|
|
var params = """
|
|
@@ -221,7 +230,7 @@ public class AwoaraServiceImpl implements AwoaraService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Config readConfig(String productKey, String deviceName) {
|
|
|
|
|
|
|
+ public DeviceConfig readConfig(String productKey, String deviceName) {
|
|
|
var params = """
|
|
var params = """
|
|
|
{
|
|
{
|
|
|
"version": "2.0",
|
|
"version": "2.0",
|
|
@@ -229,12 +238,12 @@ public class AwoaraServiceImpl implements AwoaraService {
|
|
|
"params": []
|
|
"params": []
|
|
|
}
|
|
}
|
|
|
""";
|
|
""";
|
|
|
- return doRequest(productKey, deviceName, params, new TypeReference<AwoaraResponse<Config>>() {
|
|
|
|
|
|
|
+ return doRequest(productKey, deviceName, params, new TypeReference<AwoaraResponse<DeviceConfig>>() {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void writeConfig(String productKey, String deviceName, Config config) {
|
|
|
|
|
|
|
+ public void writeConfig(String productKey, String deviceName, DeviceConfig deviceConfig) {
|
|
|
var params = """
|
|
var params = """
|
|
|
{
|
|
{
|
|
|
"version": "2.0",
|
|
"version": "2.0",
|
|
@@ -242,10 +251,10 @@ public class AwoaraServiceImpl implements AwoaraService {
|
|
|
"params": {
|
|
"params": {
|
|
|
"version":2,
|
|
"version":2,
|
|
|
"maintenance_mode": 0,
|
|
"maintenance_mode": 0,
|
|
|
- "user_message.1": "超级进化车生活",
|
|
|
|
|
|
|
+ "user_message.1": "超级进化车生活2",
|
|
|
"user_message.2": "客服电话:13018061579",
|
|
"user_message.2": "客服电话:13018061579",
|
|
|
"sensor_water": 0,
|
|
"sensor_water": 0,
|
|
|
- "price_space": 10,
|
|
|
|
|
|
|
+ "price_space": 0,
|
|
|
"price_water": 150,
|
|
"price_water": 150,
|
|
|
"price_foam": 250,
|
|
"price_foam": 250,
|
|
|
"price_tap": 100,
|
|
"price_tap": 100,
|
|
@@ -272,6 +281,13 @@ public class AwoaraServiceImpl implements AwoaraService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
""";
|
|
""";
|
|
|
- doRequest(productKey, deviceName, params, null);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ var json = new JSONObject();
|
|
|
|
|
+ json.put("version", "2.0");
|
|
|
|
|
+ json.put("method", "write_config");
|
|
|
|
|
+ json.put("params", deviceConfig);
|
|
|
|
|
+
|
|
|
|
|
+// doRequest(productKey, deviceName, params, null);
|
|
|
|
|
+ doRequest(productKey, deviceName, gson.toJson(json).replaceAll("1\"", ".1\"").replaceAll("2\"", ".2\""), null);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|