package com.tievd.jyz.mqtt.command;
|
|
import com.alibaba.fastjson.JSON;
|
import com.tievd.jyz.constants.SystemConstant;
|
import com.tievd.jyz.mqtt.dto.EventResourceDTO;
|
import com.tievd.jyz.mqtt.dto.MqttParamDTO;
|
import com.tievd.jyz.mqtt.dto.SyncBaseUpdateDTO;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
|
/**
|
* 业务平台根据业务流转需求,获取事件相关资源。
|
* @author Wang
|
*
|
*/
|
public class EventResourceCommand implements Command {
|
|
private Logger log = LoggerFactory.getLogger(EventResourceCommand.class);
|
|
private final static String TYPE = "eventResource";
|
|
private MqttCommandReceiver commandReceiver;
|
|
private String sendTopicName;
|
|
private String sn;
|
|
private EventResourceDTO eventResourceDTO;
|
|
private MqttParamDTO obj = new MqttParamDTO();
|
|
public EventResourceCommand(MqttCommandReceiver commandReceiver, EventResourceDTO eventResourceDTO, String sendTopicName, String sn) {
|
super();
|
this.commandReceiver = commandReceiver;
|
this.sendTopicName = sendTopicName;
|
this.sn = sn;
|
this.eventResourceDTO = eventResourceDTO;
|
}
|
|
@Override
|
public int init() {
|
obj.setType(TYPE);
|
obj.setSn(sn);
|
obj.setData(eventResourceDTO);
|
obj.setTime(String.valueOf(System.currentTimeMillis()));
|
return SystemConstant.DEAL_OK;
|
}
|
|
@Override
|
public int execute() {
|
Integer ret = SystemConstant.DEAL_OK;
|
int status = commandReceiver.send(JSON.toJSONString(obj),new StringBuilder(sendTopicName).append(sn).toString());
|
if(status == SystemConstant.DEAL_FAIL ) {
|
ret = SystemConstant.DEAL_FAIL;
|
}
|
return ret;
|
}
|
|
}
|