sendd
This commit is contained in:
@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class CommandDTO {
|
public class CommandDTO {
|
||||||
|
|
||||||
private String clientld;
|
private String clientId;
|
||||||
private Integer command;
|
private Integer command;
|
||||||
private Integer providerld;
|
private Integer providerId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,12 +81,16 @@ public class ElectronicFenceServiceImpl implements ElectronicFenceService {
|
|||||||
boolean currentlyInFence = isPointInPolygon(testPoint, polygon);
|
boolean currentlyInFence = isPointInPolygon(testPoint, polygon);
|
||||||
// 出圈时 fuelStatus=油路正常, 就下断电指令; 回到圈内时 fuelStatus=油路断开,就上电
|
// 出圈时 fuelStatus=油路正常, 就下断电指令; 回到圈内时 fuelStatus=油路断开,就上电
|
||||||
String fuleStatus = deviceLocation.getFuelStatus();
|
String fuleStatus = deviceLocation.getFuelStatus();
|
||||||
|
|
||||||
|
log.info("fuleStatus:" + fuleStatus);
|
||||||
// 状态发生变化时执行相应操作
|
// 状态发生变化时执行相应操作
|
||||||
if (currentlyInFence && "油路断开".equals(fuleStatus)) {
|
if (currentlyInFence && "油路断开".equals(fuleStatus)) {
|
||||||
// 进入围栏 - 发出放电指令
|
// 进入围栏 - 发出放电指令
|
||||||
|
log.info("发送通电指令给车辆");
|
||||||
sendPowerOnCommand(clientId,iotBrands);
|
sendPowerOnCommand(clientId,iotBrands);
|
||||||
} else if (!currentlyInFence && "油路正常".equals(fuleStatus)) {
|
} else if (!currentlyInFence && "油路正常".equals(fuleStatus)) {
|
||||||
// 超出围栏 - 发出断电指令
|
// 超出围栏 - 发出断电指令
|
||||||
|
log.info("发送断电指令给车辆");
|
||||||
sendPowerOffCommand(clientId,iotBrands);
|
sendPowerOffCommand(clientId,iotBrands);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,33 +158,36 @@ public class ElectronicFenceServiceImpl implements ElectronicFenceService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送通电指令
|
* 发送通电指令
|
||||||
*
|
*指令: 1-设备复位, 2-断油电, 3-恢复油电, 4-立即定位
|
||||||
* @param clientId 车辆识别号
|
* @param clientId 车辆识别号
|
||||||
*/
|
*/
|
||||||
private void sendPowerOnCommand(String clientId,String iotBrands) {
|
private void sendPowerOnCommand(String clientId,String iotBrands) {
|
||||||
// 实际实现发送通电指令到设备
|
// 实际实现发送通电指令到设备
|
||||||
CommandDTO commandDTO = new CommandDTO();
|
CommandDTO commandDTO = new CommandDTO();
|
||||||
|
|
||||||
commandDTO.setClientld(clientId);
|
commandDTO.setClientId(clientId);
|
||||||
commandDTO.setCommand(3);
|
commandDTO.setCommand(3);
|
||||||
commandDTO.setProviderld(Integer.parseInt(iotBrands));
|
commandDTO.setProviderId(Integer.parseInt(iotBrands));
|
||||||
|
|
||||||
|
//String response = "";
|
||||||
String response = forwardData(URL+"/device/8304", JSON.toJSONString(commandDTO));
|
String response = forwardData(URL+"/device/8304", JSON.toJSONString(commandDTO));
|
||||||
|
|
||||||
log.info("发送通电指令给车辆: {} , 响应: {}" + clientId ,response);
|
log.info("发送通电指令给车辆: {} , 响应: {}" + clientId ,response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送断电指令
|
* 发送断电指令
|
||||||
*
|
*指令: 1-设备复位, 2-断油电, 3-恢复油电, 4-立即定位
|
||||||
* @param clientId 车辆识别号
|
* @param clientId 车辆识别号
|
||||||
*/
|
*/
|
||||||
private void sendPowerOffCommand(String clientId,String iotBrands) {
|
private void sendPowerOffCommand(String clientId,String iotBrands) {
|
||||||
// 实际实现发送断电指令到设备
|
// 实际实现发送断电指令到设备
|
||||||
CommandDTO commandDTO = new CommandDTO();
|
CommandDTO commandDTO = new CommandDTO();
|
||||||
commandDTO.setClientld(clientId);
|
commandDTO.setClientId(clientId);
|
||||||
commandDTO.setCommand(2);
|
commandDTO.setCommand(2);
|
||||||
commandDTO.setProviderld(Integer.parseInt(iotBrands));
|
commandDTO.setProviderId(Integer.parseInt(iotBrands));
|
||||||
|
|
||||||
|
|
||||||
|
//String response = "";
|
||||||
String response = forwardData(URL+"/device/8304", JSON.toJSONString(commandDTO));
|
String response = forwardData(URL+"/device/8304", JSON.toJSONString(commandDTO));
|
||||||
log.info("发送断电指令给车辆: {} , 响应: {}" + clientId ,response);
|
log.info("发送断电指令给车辆: {} , 响应: {}" + clientId ,response);
|
||||||
}
|
}
|
||||||
@ -204,7 +211,7 @@ public class ElectronicFenceServiceImpl implements ElectronicFenceService {
|
|||||||
httpPost.setHeader("User-Agent", "SczxSync/1.0");
|
httpPost.setHeader("User-Agent", "SczxSync/1.0");
|
||||||
|
|
||||||
|
|
||||||
StringEntity entity = new StringEntity(JSON.toJSONString(data), StandardCharsets.UTF_8);
|
StringEntity entity = new StringEntity(data, StandardCharsets.UTF_8);
|
||||||
httpPost.setEntity(entity);
|
httpPost.setEntity(entity);
|
||||||
|
|
||||||
// 设置超时配置
|
// 设置超时配置
|
||||||
|
|||||||
Reference in New Issue
Block a user