diff --git a/src/main/java/com/sczx/sync/dto/CommandDTO.java b/src/main/java/com/sczx/sync/dto/CommandDTO.java index b6eeea7..2c54044 100644 --- a/src/main/java/com/sczx/sync/dto/CommandDTO.java +++ b/src/main/java/com/sczx/sync/dto/CommandDTO.java @@ -6,7 +6,7 @@ import lombok.Data; @Data public class CommandDTO { - private String clientld; + private String clientId; private Integer command; - private Integer providerld; + private Integer providerId; } diff --git a/src/main/java/com/sczx/sync/service/impl/ElectronicFenceServiceImpl.java b/src/main/java/com/sczx/sync/service/impl/ElectronicFenceServiceImpl.java index 1b4f88f..0b1070d 100644 --- a/src/main/java/com/sczx/sync/service/impl/ElectronicFenceServiceImpl.java +++ b/src/main/java/com/sczx/sync/service/impl/ElectronicFenceServiceImpl.java @@ -81,12 +81,16 @@ public class ElectronicFenceServiceImpl implements ElectronicFenceService { boolean currentlyInFence = isPointInPolygon(testPoint, polygon); // 出圈时 fuelStatus=油路正常, 就下断电指令; 回到圈内时 fuelStatus=油路断开,就上电 String fuleStatus = deviceLocation.getFuelStatus(); + + log.info("fuleStatus:" + fuleStatus); // 状态发生变化时执行相应操作 if (currentlyInFence && "油路断开".equals(fuleStatus)) { // 进入围栏 - 发出放电指令 + log.info("发送通电指令给车辆"); sendPowerOnCommand(clientId,iotBrands); } else if (!currentlyInFence && "油路正常".equals(fuleStatus)) { // 超出围栏 - 发出断电指令 + log.info("发送断电指令给车辆"); sendPowerOffCommand(clientId,iotBrands); } @@ -154,33 +158,36 @@ public class ElectronicFenceServiceImpl implements ElectronicFenceService { /** * 发送通电指令 - * + *指令: 1-设备复位, 2-断油电, 3-恢复油电, 4-立即定位 * @param clientId 车辆识别号 */ private void sendPowerOnCommand(String clientId,String iotBrands) { // 实际实现发送通电指令到设备 CommandDTO commandDTO = new CommandDTO(); - commandDTO.setClientld(clientId); + commandDTO.setClientId(clientId); commandDTO.setCommand(3); - commandDTO.setProviderld(Integer.parseInt(iotBrands)); + commandDTO.setProviderId(Integer.parseInt(iotBrands)); + + //String response = ""; String response = forwardData(URL+"/device/8304", JSON.toJSONString(commandDTO)); + log.info("发送通电指令给车辆: {} , 响应: {}" + clientId ,response); } /** * 发送断电指令 - * + *指令: 1-设备复位, 2-断油电, 3-恢复油电, 4-立即定位 * @param clientId 车辆识别号 */ private void sendPowerOffCommand(String clientId,String iotBrands) { // 实际实现发送断电指令到设备 CommandDTO commandDTO = new CommandDTO(); - commandDTO.setClientld(clientId); + commandDTO.setClientId(clientId); commandDTO.setCommand(2); - commandDTO.setProviderld(Integer.parseInt(iotBrands)); - + commandDTO.setProviderId(Integer.parseInt(iotBrands)); + //String response = ""; String response = forwardData(URL+"/device/8304", JSON.toJSONString(commandDTO)); log.info("发送断电指令给车辆: {} , 响应: {}" + clientId ,response); } @@ -204,7 +211,7 @@ public class ElectronicFenceServiceImpl implements ElectronicFenceService { 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); // 设置超时配置