|
|
@@ -3,7 +3,7 @@ package com.zksy.pole.service.impl;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zksy.pole.MQTTServer.request.MqttRequest;
|
|
|
import com.zksy.pole.MQTTServer.server.MQTTServer;
|
|
|
-import com.zksy.pole.domain.dto.ReportEnvironmentalDataDto;
|
|
|
+import com.zksy.pole.domain.dto.*;
|
|
|
import com.zksy.pole.service.InstructionIssuanceServer;
|
|
|
import io.netty.buffer.Unpooled;
|
|
|
import io.netty.channel.Channel;
|
|
|
@@ -39,6 +39,84 @@ public class InstructionIssuanceServerImpl implements InstructionIssuanceServer
|
|
|
return "ok";
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String equipmentStatus(EquipmentStatusDto dto) {
|
|
|
+ MqttQoS qos = MqttQoS.AT_MOST_ONCE;
|
|
|
+ String topic = "down/light/"+dto.getLightNums();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cmd",dto.getCmd());
|
|
|
+ jsonObject.put("package_id","1050");
|
|
|
+ jsonObject.put("light_nums",dto.getLightNums());
|
|
|
+ writeAndFlush(qos,topic,jsonObject);
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String scenarioStrategy(ScenarioStrategyDto dto) {
|
|
|
+ MqttQoS qos = MqttQoS.AT_MOST_ONCE;;
|
|
|
+ String topic = "down/light/"+dto.getLightNums();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cmd",dto.getCmd());
|
|
|
+ jsonObject.put("package_id","1050");
|
|
|
+ jsonObject.put("light_nums",dto.getLightNums());
|
|
|
+ jsonObject.put("id",15);
|
|
|
+ jsonObject.put("type",dto.getType());
|
|
|
+ jsonObject.put("status",dto.getStatus());
|
|
|
+ jsonObject.put("start_time",dto.getStart_time());
|
|
|
+ jsonObject.put("end_time",dto.getEnd_time());
|
|
|
+ jsonObject.put("params",dto.getParams());
|
|
|
+ writeAndFlush(qos,topic,jsonObject);
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String delScenarioStrategy(DelScenarioStrategyDto dto) {
|
|
|
+ MqttQoS qos = MqttQoS.AT_MOST_ONCE;;
|
|
|
+ String topic = "down/light/"+dto.getLightNums();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cmd",dto.getCmd());
|
|
|
+ jsonObject.put("package_id","1050");
|
|
|
+ jsonObject.put("light_nums",dto.getLightNums());
|
|
|
+ jsonObject.put("id",15);
|
|
|
+ jsonObject.put("tag",dto.getTag());
|
|
|
+ writeAndFlush(qos,topic,jsonObject);
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String setGatewayTime(SetGatewayTimeDto dto) {
|
|
|
+ MqttQoS qos = MqttQoS.AT_MOST_ONCE;
|
|
|
+ String topic = "down/light/"+dto.getLightNums();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cmd",dto.getCmd());
|
|
|
+ jsonObject.put("package_id","1050");
|
|
|
+ jsonObject.put("timestamp",dto.getTimestamp());
|
|
|
+ writeAndFlush(qos,topic,jsonObject);
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String reRegistered(EquipmentStatusDto dto) {
|
|
|
+ MqttQoS qos = MqttQoS.AT_MOST_ONCE;
|
|
|
+ String topic = "down/light/"+dto.getLightNums();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cmd",dto.getCmd());
|
|
|
+ writeAndFlush(qos,topic,jsonObject);
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String relayControl(RelayControlDto dto) {
|
|
|
+ MqttQoS qos = MqttQoS.AT_MOST_ONCE;
|
|
|
+ String topic = "down/light/"+dto.getLightNums();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cmd",dto.getCmd());
|
|
|
+ jsonObject.put("package_id",dto.getPackageId());
|
|
|
+ jsonObject.put("params",dto.getParams());
|
|
|
+ writeAndFlush(qos,topic,jsonObject);
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+
|
|
|
public void writeAndFlush(MqttQoS qos,String topic,JSONObject jsonObject){
|
|
|
MqttRequest request = new MqttRequest((jsonObject.toString().getBytes()));
|
|
|
MqttPublishMessage pubMessage = (MqttPublishMessage) MqttMessageFactory.newMessage(
|