Commit 4b57722b by 111-PC\111

[+]红外修改

1 parent 1a03e9d3
......@@ -2,6 +2,7 @@ package com.glsx.smart.pojo;
import com.alibaba.nacos.common.utils.MD5Utils;
import lombok.Data;
import scala.Byte;
import sun.security.provider.MD5;
/**
......@@ -20,6 +21,6 @@ public class ExecuteTaskVo {
private String msg;
private String phone;
private String channel="1";
private int channel=1;
}
......@@ -215,12 +215,11 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
continue;
}
Map<String, Object> objectMap = buildOrderIssueParam(executeTaskVo, order_value);
jsonObject = HttpUtil.sendPost(orderIssueurl.replace("{device_id}", executeTaskVo.getChannel().equals(Constants.USER_CHANNEL_TUYA)?devideId:executeTaskVo.getPhone()).replace("{resource}",executeTaskVo.getChannel()), JSONObject.toJSONString(objectMap), new HashMap<>());
jsonObject = HttpUtil.sendPost(orderIssueurl, JSONObject.toJSONString(objectMap), new HashMap<>());
} else {
// 下发红外遥控指令
Map<String, Object> ordermap = new HashMap<>();
ordermap.put("key", executeTaskVo.getOrderVal());
jsonObject = HttpUtil.sendPost(instructionInfIssue.replace("{remote_id}", remoteId).replace("{infrared_id}", devideId), JSONObject.toJSONString(ordermap), new HashMap<>());
Map<String, Object> objectMap = buildOrderIssueInfParam(executeTaskVo);
jsonObject = HttpUtil.sendPost(instructionInfIssue, JSONObject.toJSONString(objectMap), new HashMap<>());
}
if (jsonObject != null) {
ResponseVo responseVo = JSONObject.toJavaObject(jsonObject, ResponseVo.class);
......@@ -255,26 +254,68 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
return orderResponseList;
}
/**
* 构建红外指令下发
*
* @param executeTaskVo
* @return
*/
private Map<String, Object> buildOrderIssueInfParam(ExecuteTaskVo executeTaskVo) {
int channel = executeTaskVo.getChannel();
Map<String, Object> requestMap = new HashMap<>();
Map<String, Object> datamap = new HashMap<>();
if (channel==Constants.USER_CHANNEL_TUYA) {
datamap.put("key", executeTaskVo.getOrderVal());
requestMap.put("data", datamap);
requestMap.put("channel", executeTaskVo.getChannel());
requestMap.put("deviceId", executeTaskVo.getSelect());
requestMap.put("remoteId", executeTaskVo.getRemoteId());
log.info("涂鸦发送的红外指令{}", JSON.toJSONString(requestMap));
} else if(channel==Constants.USER_CHANNEL_AQARA){
datamap.put("keyId", executeTaskVo.getOrderVal());
datamap.put("acKey", executeTaskVo.getOrderVal());
datamap.put("did", executeTaskVo.getRemoteId());
requestMap.put("data", datamap);
requestMap.put("channel", executeTaskVo.getChannel());
requestMap.put("phone", executeTaskVo.getPhone());
log.info("aqara发送的红外指令{}", JSON.toJSONString(requestMap));
}
return requestMap;
}
/**
* 构建设备指令下发参数
*
* @param executeTaskVo
* @param order_value
* @return
*/
private Map<String, Object> buildOrderIssueParam(ExecuteTaskVo executeTaskVo, String order_value) {
String channel = executeTaskVo.getChannel();
String valueType = executeTaskVo.getValue();
Map<String, Object> mapMap = new HashMap<>();
int channel = executeTaskVo.getChannel();
String valueType = executeTaskVo.getValType();
Map<String, Object> ordermaps = new HashMap<>();
List<Map<String, Object>> maps = new ArrayList<>();
Map<String, Object> ordermap = new HashMap<>();
if(channel.equals(Constants.USER_CHANNEL_TUYA)) {
if (channel==Constants.USER_CHANNEL_TUYA) {
ordermap.put("code", executeTaskVo.getOrder());
ordermap.put("value", revertType(valueType, order_value));
maps.add(ordermap);
ordermaps.put("commands", maps);
log.info("涂鸦发送的指令{}", JSON.toJSONString(maps));
}else if(channel.equals(Constants.USER_CHANNEL_AQARA)){
ordermap.put(executeTaskVo.getOrder(),revertType(valueType, order_value));
maps.add(ordermap);
ordermaps.put("attrs", maps);
mapMap.put("data", ordermaps);
mapMap.put("channel", executeTaskVo.getChannel());
mapMap.put("deviceId", executeTaskVo.getSelect());
log.info("涂鸦发送的指令{}", JSON.toJSONString(mapMap));
} else if (channel==Constants.USER_CHANNEL_AQARA) {
ordermap.put(executeTaskVo.getOrder(), revertType(valueType, order_value));
ordermaps.put("attrs", ordermap);
ordermaps.put("did", executeTaskVo.getSelect());
log.info("aqara发送的指令{}", JSON.toJSONString(ordermaps));
mapMap.put("data", ordermaps);
mapMap.put("phone", executeTaskVo.getPhone());
mapMap.put("channel", executeTaskVo.getChannel());
log.info("aqara发送的指令{}", JSON.toJSONString(mapMap));
}
return ordermaps;
return mapMap;
}
/**
......@@ -288,18 +329,18 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
Map<String, Object> map = sceneMapper.getBySourceAndUserId(scene.getId());
String user_id = map.get("user_id") + "";
Map<String, String> paramMap = new HashMap<>();
String source=map.get("source") + "";
String source = map.get("source") + "";
paramMap.put("alias", user_id);
paramMap.put("deviceType", map.get("source") + "");
paramMap.put("title", title);
paramMap.put("body", msg);
paramMap.put("msgBody", msg);
saveMegInfo(user_id, title, msg);
if(StringUtils.isEmpty(source)){
if (StringUtils.isEmpty(source)) {
return;
}
try {
log.info("通知入参{}",JSONObject.toJSONString(paramMap));
log.info("通知入参{}", JSONObject.toJSONString(paramMap));
JSONObject jsonObject = HttpUtil.sendPost(infoUrl, JSONObject.toJSONString(paramMap), new HashMap<>());
if (jsonObject != null) {
String code = jsonObject.get("code") + "";
......@@ -361,10 +402,10 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
content = MessageFormat.format("您配置的{0}场景未顺利执行,点击可查看详情。", scene_name);
}
paramMap.put("body", content);
String context = buildBody(collect,scene_name);
String context = buildBody(collect, scene_name);
paramMap.put("msgBody", context);
saveMegInfo(user_id, title, context);
if(StringUtils.isEmpty(source)){
if (StringUtils.isEmpty(source)) {
return;
}
try {
......@@ -379,7 +420,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
}
} catch (IOException e) {
e.printStackTrace();
log.info("下发通知异常{}",e);
log.info("下发通知异常{}", e);
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!