|
|
|
@ -4,6 +4,7 @@ import com.shxy.xymanager_common.exception.ApiException;
|
|
|
|
|
import com.shxy.xymanager_common.model.mqtt.MessageSend;
|
|
|
|
|
import com.shxy.xymanager_common.model.mqtt.ParamArray;
|
|
|
|
|
import com.shxy.xymanager_common.model.mqtt.Paras;
|
|
|
|
|
import com.shxy.xymanager_common.util.DateUtil;
|
|
|
|
|
import com.shxy.xymanager_service.mqtt.MqttPublisherService;
|
|
|
|
|
import com.shxy.xymanager_service.service.MqttService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -12,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -47,7 +49,9 @@ public class MqttServiceImpl implements MqttService {
|
|
|
|
|
private MessageSend buildMessage(Map<String, String> map) {
|
|
|
|
|
MessageSend msg = new MessageSend();
|
|
|
|
|
Paras paras = msg.getParas();
|
|
|
|
|
Integer channel, preset, ctrl;
|
|
|
|
|
Integer channel, preset, ctrl, flag, group;
|
|
|
|
|
Long time;
|
|
|
|
|
String str;
|
|
|
|
|
String act = map.get("act");
|
|
|
|
|
switch (act) {
|
|
|
|
|
case "capture":
|
|
|
|
@ -70,34 +74,49 @@ public class MqttServiceImpl implements MqttService {
|
|
|
|
|
paras.setChannelId(String.valueOf(channel));
|
|
|
|
|
ctrl = Integer.parseInt(map.get("ctrl"));
|
|
|
|
|
paras.setActionCommand(ctrl);
|
|
|
|
|
if (ctrl == 2 || ctrl == 9) {
|
|
|
|
|
if (ctrl == 1 || ctrl == 2 || ctrl == 8 || ctrl == 9) {
|
|
|
|
|
preset = Integer.parseInt(map.get("preset"));
|
|
|
|
|
paras.setActionCommandParameter(preset);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "schedule":
|
|
|
|
|
Integer flag = Integer.parseInt(map.get("flag"));
|
|
|
|
|
Integer scheduleChannel = Integer.parseInt(map.get("channel"));
|
|
|
|
|
paras.setChannelNumber(scheduleChannel);
|
|
|
|
|
flag = Integer.parseInt(map.get("flag"));
|
|
|
|
|
channel = Integer.parseInt(map.get("channel"));
|
|
|
|
|
paras.setChannelNumber(channel);
|
|
|
|
|
if (flag == 0) {
|
|
|
|
|
msg.setServiceId("PlatformQueryDataCommandLssueService");
|
|
|
|
|
msg.setCmd("getCaptureTimesTaskInformation");
|
|
|
|
|
} else {
|
|
|
|
|
msg.setServiceId("PlatformSettingParameterLssueService");
|
|
|
|
|
msg.setCmd("setCaptureTimesTaskParameter");
|
|
|
|
|
Integer group = Integer.parseInt(map.get("group"));
|
|
|
|
|
group = Integer.parseInt(map.get("group"));
|
|
|
|
|
paras.setGroupNumber(group);
|
|
|
|
|
List<ParamArray> paramArrayList = new ArrayList<>();
|
|
|
|
|
for (int i = 1; i <= group; i++) {
|
|
|
|
|
ParamArray paramArray = new ParamArray();
|
|
|
|
|
paramArray.setHour(Integer.parseInt(map.get("hour"+i)));
|
|
|
|
|
paramArray.setMinute(Integer.parseInt(map.get("min"+i)));
|
|
|
|
|
paramArray.setPresetPosition(Integer.parseInt(map.get("preset"+i)));
|
|
|
|
|
paramArray.setHour(Integer.parseInt(map.get("hour" + i)));
|
|
|
|
|
paramArray.setMinute(Integer.parseInt(map.get("min" + i)));
|
|
|
|
|
paramArray.setPresetPosition(Integer.parseInt(map.get("preset" + i)));
|
|
|
|
|
paramArrayList.add(paramArray);
|
|
|
|
|
}
|
|
|
|
|
paras.setParamArray(paramArrayList);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "time":
|
|
|
|
|
flag = Integer.parseInt(map.get("flag"));
|
|
|
|
|
if (flag == 0) {
|
|
|
|
|
msg.setServiceId("PlatformQueryDataCommandLssueService");
|
|
|
|
|
msg.setCmd("getDeviceTime");
|
|
|
|
|
} else {
|
|
|
|
|
msg.setServiceId("PlatformSettingParameterLssueService");
|
|
|
|
|
msg.setCmd("setDeviceTime");
|
|
|
|
|
time = Long.parseLong(map.get("time"));
|
|
|
|
|
Date date = new Date(time * 1000);
|
|
|
|
|
str = DateUtil.format(date, "yyyy-MM-ddTHH:mm:ssZ");
|
|
|
|
|
paras.setTime(str);
|
|
|
|
|
paras.setTimingType(0);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new ApiException(act + "暂时无法处理");
|
|
|
|
|
}
|
|
|
|
|