| | |
| | | import com.sandu.ximon.admin.service.*; |
| | | import com.sandu.ximon.admin.utils.LogUtils; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.dao.domain.C3mOrder; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.enums.OrderStatus; |
| | |
| | | |
| | | @Override |
| | | public void process(String productKey, String deviceName, CommonFrame frame) { |
| | | String functionCode = frame.getPayload().substring(2, 4); |
| | | //TODO |
| | | if (!frame.getPayload().contains("0000048E")) { |
| | | if (!"32313243305005ffad36ffff".equals(deviceName)) { |
| | | log.info("不要处理0000048E之外的充电桩!"); |
| | | return; |
| | | } |
| | | |
| | | |
| | | String functionCode = frame.getPayload().substring(2, 4); |
| | | if (C3ChargingEnum.NETWORK_REQUEST.getCode().equals(functionCode)) { |
| | | A5C3CommonReportInnerFrame netRequestFrame = new A5C3CommonReportInnerFrame().transformFrame(frame.getPayload()); |
| | | log.info("C3充电桩上报处理_netRequestFrame"); |
| | |
| | | /** |
| | | * 读取心跳包,判断剩余金额和已充电量,统计到缓存中正在进行的订单。 |
| | | */ |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = c3ChargingService.ReadTheHeartbeatPackage(completeRequestFrame.getDestinationAddress(), true); |
| | | if (aPackage == null) { |
| | | LogUtils.error("{ 充电桩(" + completeRequestFrame.getDestinationAddress() + ")充电结束上报读取心跳包失败,请检查充电桩是否出现故障! }"); |
| | | return; |
| | | if (completeRequestFrame != null) { |
| | | C3mCharging one = SpringContextHolder.getBean(C3ChargingService.class). |
| | | getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, completeRequestFrame.getMcuUdid()).last("limit 1")); |
| | | if (one == null) { |
| | | return; |
| | | } |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = c3ChargingService.ReadTheHeartbeatPackage(one.getC3Id(), true); |
| | | if (aPackage == null) { |
| | | LogUtils.error("{ 充电桩(" + completeRequestFrame.getDestinationAddress() + ")充电结束上报读取心跳包失败,请检查充电桩是否出现故障! }"); |
| | | return; |
| | | } |
| | | orderService.stopCharingOrder(aPackage); |
| | | } |
| | | orderService.stopCharingOrder(aPackage); |
| | | |
| | | |
| | | } else if (C3ChargingEnum.CHARGE_STOP.getCode().equals(functionCode)) { |
| | | log.info("心跳响应——充电中断"); |
| | | A5C3CommonReportInnerFrame stopRequestFrame = new A5C3CommonReportInnerFrame().transformFrame(frame.getPayload()); |
| | | log.info("C3充电桩上报处理_stopRequestFrame"); |
| | | log.info(stopRequestFrame.toString()); |
| | | if (stopRequestFrame != null) { |
| | | C3mCharging one = SpringContextHolder.getBean(C3ChargingService.class). |
| | | getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, stopRequestFrame.getMcuUdid()).last("limit 1")); |
| | | if (one == null) { |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * 读取心跳包,判断剩余金额和已充电量,统计到缓存中正在进行的订单。 |
| | | */ |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = c3ChargingService.ReadTheHeartbeatPackage(stopRequestFrame.getDestinationAddress(), true); |
| | | if (aPackage == null) { |
| | | LogUtils.error("{ 充电桩(" + stopRequestFrame.getDestinationAddress() + ")充电结束上报读取心跳包失败,请检查充电桩是否出现故障! }"); |
| | | return; |
| | | /** |
| | | * 读取心跳包,判断剩余金额和已充电量,统计到缓存中正在进行的订单。 |
| | | */ |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = c3ChargingService.ReadTheHeartbeatPackage(one.getC3Id(), true); |
| | | if (aPackage == null) { |
| | | LogUtils.error("{ 充电桩(" + stopRequestFrame.getDestinationAddress() + ")充电结束上报读取心跳包失败,请检查充电桩是否出现故障! }"); |
| | | return; |
| | | } |
| | | orderService.stopCharingOrder(aPackage); |
| | | } |
| | | orderService.stopCharingOrder(aPackage); |
| | | |
| | | } else if (C3ChargingEnum.ERROR_CODE.getCode().equals(functionCode)) { |
| | | log.info("心跳响应——故障"); |
| | | A5C3ErrorCodeReportInnerFrame errorCodeRequestFrame = new A5C3ErrorCodeReportInnerFrame().transformFrame(frame.getPayload()); |
| | |
| | | System.out.println("数据校验异常!"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |