|
@@ -1,6 +1,7 @@
|
|
|
package com.middle.platform.manage.biz.service;
|
|
package com.middle.platform.manage.biz.service;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.middle.platform.common.constant.Global;
|
|
import com.middle.platform.common.constant.Global;
|
|
|
import com.middle.platform.common.exception.BusinessException;
|
|
import com.middle.platform.common.exception.BusinessException;
|
|
@@ -39,6 +40,17 @@ public class IotCloudService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private IotProductService iotProductService;
|
|
private IotProductService iotProductService;
|
|
|
|
|
|
|
|
|
|
+ private Object objStrToJSON(Object object) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (object instanceof String str) {
|
|
|
|
|
+ return JSONObject.parseObject(str);
|
|
|
|
|
+ }
|
|
|
|
|
+ return JSONObject.parseObject(JSONObject.toJSONString(object));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return object;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void saveCloud(Long productId, String cloudText) {
|
|
private void saveCloud(Long productId, String cloudText) {
|
|
|
ThreadTask.addJob(() -> {
|
|
ThreadTask.addJob(() -> {
|
|
|
try {
|
|
try {
|
|
@@ -110,7 +122,7 @@ public class IotCloudService {
|
|
|
// 云函数测试
|
|
// 云函数测试
|
|
|
try {
|
|
try {
|
|
|
JSONArray objects = new JSONArray();
|
|
JSONArray objects = new JSONArray();
|
|
|
- objects.add(iotCloudTest.getData());
|
|
|
|
|
|
|
+ objects.add(objStrToJSON(iotCloudTest.getData()));
|
|
|
return OkHttpUtils.builder().url(cloud + "/cloud/" + iotCloudTest.getProductId() + ".js").postRawJson(objects).sync();
|
|
return OkHttpUtils.builder().url(cloud + "/cloud/" + iotCloudTest.getProductId() + ".js").postRawJson(objects).sync();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("云函数请求异常:{}", e.getMessage(), e);
|
|
log.error("云函数请求异常:{}", e.getMessage(), e);
|