| | |
| | | newC3Mac = SupplementUtils.suppleZero(index, 8); |
| | | if (!c3macList.contains(newC3Mac)) { |
| | | //失败重发一次 |
| | | String s = SetAddress(c3Mac, newC3Mac, true); |
| | | String s = SetAddress(one.getC3Id(), newC3Mac, true); |
| | | if (!"操作成功".equals(s)) { |
| | | LogUtils.error("初始化充电桩失败!"); |
| | | return false; |
| | |
| | | //同步时间戳 |
| | | System.out.println("同步时间戳开始"); |
| | | String date = new SimpleDateFormat("yyMMddHHmmss").format(new Date()); |
| | | String s = SetCalendar(newC3Mac, Integer.parseInt(date.substring(0, 2)), Integer.parseInt(date.substring(2, 4)), |
| | | String s = SetCalendar(one.getC3Id(), Integer.parseInt(date.substring(0, 2)), Integer.parseInt(date.substring(2, 4)), |
| | | Integer.parseInt(date.substring(4, 6)), Integer.parseInt(date.substring(6, 8)), |
| | | Integer.parseInt(date.substring(8, 10)), Integer.parseInt(date.substring(10, 12)), true); |
| | | if (!"操作成功".equals(s)) { |
| | |
| | | Set<String> keys = RedisUtils.getBean().keys(C3mRedisConstant.C3_STATUS.getCode() + "*"); |
| | | |
| | | C3mRedisConfig.reFlushTime(keys.size()); |
| | | String time1 = SetHeartbeatPacketTimeCharging(newC3Mac, C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME) * 2, false, true); |
| | | String time1 = SetHeartbeatPacketTimeCharging(one.getC3Id(), C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME) * 2, false, true); |
| | | LogUtils.error("C3空闲心跳包时间同步响应结果:" + time1); |
| | | String time2 = SetHeartbeatPacketTimeCharging(newC3Mac, C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME), true, true); |
| | | String time2 = SetHeartbeatPacketTimeCharging(one.getC3Id(), C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME), true, true); |
| | | LogUtils.error("C3充电时心跳包时间同步响应结果:" + time2); |
| | | System.out.println("设置心跳包间隔时间结束"); |
| | | |
| | |
| | | * 获取心跳包,判断在线 |
| | | */ |
| | | System.out.println("获取心跳包开始"); |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = ReadTheHeartbeatPackage(newC3Mac, true); |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = ReadTheHeartbeatPackage(one.getC3Id(), true); |
| | | if (aPackage == null) { |
| | | LogUtils.error("读取心跳包为空"); |
| | | return false; |
| | |
| | | if (one == null) { |
| | | throw new BusinessException("充电桩信息不存在!"); |
| | | } |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = ReadTheHeartbeatPackage(one.getC3Mac(), false); |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = ReadTheHeartbeatPackage(one.getC3Id(), false); |
| | | if (beatDataPackage != null) { |
| | | //充电桩ID |
| | | chargingDto.setC3Id(one.getC3Id()); |
| | |
| | | /** |
| | | * 结束充电 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String finishCharging(String c3Mac, String openId) { |
| | | public String finishCharging(Long c3Id, String openId) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | //查询 |
| | | if (openId.isEmpty()) { |
| | | throw new BusinessException("openId不能为空"); |
| | | } |
| | | //查询该充电桩最近的订单 |
| | | C3mOrder order = SpringContextHolder.getBean(C3mOrderService.class).getOne(Wrappers.lambdaQuery(C3mOrder.class) |
| | | .eq(C3mOrder::getC3Mac, c3Mac).eq(C3mOrder::getChargingStates, 0).last("limit 1")); |
| | | .eq(C3mOrder::getC3Mac, one.getC3Mac()).eq(C3mOrder::getChargingStates, 0).last("limit 1")); |
| | | |
| | | if (order == null) { |
| | | throw new BusinessException("充电桩没有进行中的订单"); |
| | |
| | | } |
| | | |
| | | C3FinishChargingReqInnerFrame c3FinishChargingReqInnerFrame = |
| | | new C3FinishChargingReqInnerFrame(c3Mac); |
| | | new C3FinishChargingReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3FinishChargingReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-结束充电", a5Frame, commonFrame); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-结束充电", a5Frame, commonFrame); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | //结束充电 更改订单状态 |
| | | C3mOrder lastOrderByC3Mac = SpringContextHolder.getBean(C3mOrderService.class).getLastOrderByC3Mac(c3Mac); |
| | | C3mOrder lastOrderByC3Mac = SpringContextHolder.getBean(C3mOrderService.class).getLastOrderByC3Mac(one.getC3Mac()); |
| | | if (lastOrderByC3Mac != null) { |
| | | //设置订单状态为已完成 |
| | | lastOrderByC3Mac.setOrderStatus(OrderStatus.COMPLETE.getStatus()); |
| | |
| | | |
| | | /** |
| | | * 查询版本 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String QueryVersion(String c3Mac) { |
| | | public String QueryVersion(Long c3Id) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3QueryVersionReqInnerFrame c3QueryVersionReqInnerFrame = |
| | | new C3QueryVersionReqInnerFrame(c3Mac); |
| | | new C3QueryVersionReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryVersionReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-版本查询", a5Frame, commonFrame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-版本查询", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | |
| | | |
| | | /** |
| | | * 查询心跳包间隔时间 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String QueryIntervalTime(String c3Mac) { |
| | | public String QueryIntervalTime(Long c3Id) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3QueryIntervalTimeReqInnerFrame c3QueryIntervalTimeReqInnerFrame = |
| | | new C3QueryIntervalTimeReqInnerFrame(c3Mac); |
| | | new C3QueryIntervalTimeReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryIntervalTimeReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-查询心跳包间隔时间", a5Frame, commonFrame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-查询心跳包间隔时间", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | |
| | | |
| | | /** |
| | | * 查询电压/电流常数 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String QueryConstant(String c3Mac) { |
| | | public String QueryConstant(Long c3Id) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | |
| | | C3QueryConstantReqInnerFrame c3QueryConstantReqInnerFrame = |
| | | new C3QueryConstantReqInnerFrame(c3Mac); |
| | | new C3QueryConstantReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryConstantReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-查询电压/电流常数", a5Frame, commonFrame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-查询电压/电流常数", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | |
| | | |
| | | /** |
| | | * 查询地址 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String QueryAddress(String c3Mac) { |
| | | public String QueryAddress(Long c3Id) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3QueryAddressReqInnerFrame c3QueryAddressReqInnerFrame = |
| | | new C3QueryAddressReqInnerFrame(c3Mac); |
| | | new C3QueryAddressReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryAddressReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-查询地址", a5Frame, commonFrame); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-查询地址", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | |
| | | |
| | | /** |
| | | * 查询故障码 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String QueryFaultCode(String c3Mac) { |
| | | public String QueryFaultCode(Long c3Id) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3QueryFaultCodeReqInnerFrame c3QueryFaultCodeReqInnerFrame = |
| | | new C3QueryFaultCodeReqInnerFrame(c3Mac); |
| | | new C3QueryFaultCodeReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryFaultCodeReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-查询故障码", a5Frame, commonFrame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-查询故障码", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | |
| | | /** |
| | | * 读心跳包 |
| | | * |
| | | * @param c3Mac |
| | | * @param resendFlag 重发标志 |
| | | */ |
| | | public A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage ReadTheHeartbeatPackage(String c3Mac, boolean resendFlag) { |
| | | public A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage ReadTheHeartbeatPackage(Long c3Id, boolean resendFlag) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3ReadTheHeartbeatPackageReqInnerFrame readTheHeartbeatPackageReqInnerFrame = |
| | | new C3ReadTheHeartbeatPackageReqInnerFrame(c3Mac); |
| | | new C3ReadTheHeartbeatPackageReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), readTheHeartbeatPackageReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame; |
| | | if (resendFlag) { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame, true); |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-读取心跳包", a5Frame, commonFrame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-读取心跳包", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | |
| | | /** |
| | | * 设置心跳包间隔时间(秒)-充电状态时/非充电状态时 |
| | | * |
| | | * @param c3Mac |
| | | * @param setTime |
| | | * @param resndFlag 重发标志 |
| | | * @return |
| | | */ |
| | | public String SetHeartbeatPacketTimeCharging(String c3Mac, int setTime, boolean flag, boolean resndFlag) { |
| | | public String SetHeartbeatPacketTimeCharging(Long c3Id, int setTime, boolean flag, boolean resndFlag) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | if (setTime <= 0) { |
| | | throw new BusinessException("设置的心跳包间隔时间错误!"); |
| | | } |
| | | C3SetHeartbeatPacketTimeReqInnerFrame setHeartbeatPacketTimeChargingReqInnerFrame = |
| | | new C3SetHeartbeatPacketTimeReqInnerFrame(c3Mac, setTime, flag); |
| | | new C3SetHeartbeatPacketTimeReqInnerFrame(one.getC3Mac(), setTime, flag); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), setHeartbeatPacketTimeChargingReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame; |
| | | if (resndFlag) { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame, true); |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置心跳包间隔时间", a5Frame, commonFrame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-设置心跳包间隔时间", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | |
| | | /** |
| | | * 设置电压/电流常数(各一字节)(默认值0xBC64) |
| | | * |
| | | * @param c3Mac |
| | | * @param constant |
| | | * @return |
| | | */ |
| | | public String SetConstant(String c3Mac, String constant) { |
| | | public String SetConstant(Long c3Id, String constant) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3SetConstantReqInnerFrame setConstantReqInnerFrame = |
| | | new C3SetConstantReqInnerFrame(c3Mac, constant); |
| | | new C3SetConstantReqInnerFrame(one.getC3Mac(), constant); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), setConstantReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置电压/电流常数", a5Frame, commonFrame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-设置电压/电流常数", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | |
| | | /** |
| | | * 设置地址 |
| | | * |
| | | * @param c3Mac |
| | | * @param address |
| | | * @return |
| | | */ |
| | | public String SetAddress(String c3Mac, String address, boolean resendFlag) { |
| | | if (address == null || address.length() != 8) { |
| | | throw new BusinessException("地址信息错误!"); |
| | | public String SetAddress(Long c3Id, String address, boolean resendFlag) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3MAC地址不存在"); |
| | | if (address == null || address.length() != 8) { |
| | | throw new BusinessException("地址信息错误!"); |
| | | } |
| | | |
| | | if (getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, address).last("limit 1")) != null) { |
| | |
| | | } |
| | | |
| | | C3SetAddressReqInnerFrame setAddressReqInnerFrame = |
| | | new C3SetAddressReqInnerFrame(c3Mac, address); |
| | | new C3SetAddressReqInnerFrame(one.getC3Mac(), address); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), setAddressReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | CommonFrame commonFrame; |
| | | if (resendFlag) { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame, true); |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置地址", a5Frame, commonFrame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-设置地址", a5Frame, commonFrame); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | //保存操作日志 |
| | | String content = "旧C3Mac地址:" + c3Mac + ";新C3Mac地址:" + address; |
| | | String content = "旧C3Mac地址:" + one.getC3Mac() + ";新C3Mac地址:" + address; |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "C3帧-设置地址", content); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | if ("操作成功".equals(operationReportInnerFrame.getState())) { |
| | | //修改成功需要更改数据库数据 |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, one.getC3Mac()).last("limit 1")); |
| | | one.setC3Mac(address); |
| | | updateById(one); |
| | | updateById(c3mCharging); |
| | | } |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | |
| | | /** |
| | | * 设置日历(同心跳包中的6字节日期时间) |
| | | * |
| | | * @param c3Mac |
| | | * @param resendFlag 是否需要重发标志 |
| | | * @return |
| | | */ |
| | | public String SetCalendar(String c3Mac, int year, int month, int day, int hour, int min, int sec, boolean resendFlag) { |
| | | |
| | | public String SetCalendar(Long c3Id, int year, int month, int day, int hour, int min, int sec, boolean resendFlag) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3SetCalendarReqInnerFrame setCalendarReqInnerFrame = |
| | | new C3SetCalendarReqInnerFrame(c3Mac, year, month, day, hour, min, sec); |
| | | new C3SetCalendarReqInnerFrame(one.getC3Mac(), year, month, day, hour, min, sec); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), setCalendarReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame; |
| | | if (resendFlag) { |
| | | //需要重发 |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame, true); |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | //不需要重发 |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置日历", a5Frame, commonFrame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-设置日历", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | |
| | | /** |
| | | * 故障码上报清除 |
| | | * |
| | | * @param c3Mac |
| | | * @return |
| | | */ |
| | | public String ClearedFaultCode(String c3Mac) { |
| | | |
| | | public String ClearedFaultCode(Long c3Id) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3ClearedFaultCodeReqInnerFrame clearedFaultCodeReqInnerFrame = |
| | | new C3ClearedFaultCodeReqInnerFrame(c3Mac); |
| | | new C3ClearedFaultCodeReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), clearedFaultCodeReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-清除故障码上报", a5Frame, commonFrame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-清除故障码上报", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | |
| | | /** |
| | | * 恢复出厂值 |
| | | * |
| | | * @param c3Mac |
| | | * @return |
| | | */ |
| | | public String RestoreFactoryValue(String c3Mac) { |
| | | |
| | | public String RestoreFactoryValue(Long c3Id) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | C3RestoreFactoryValueReqInnerFrame restoreFactoryValueReqInnerFrame = |
| | | new C3RestoreFactoryValueReqInnerFrame(c3Mac); |
| | | new C3RestoreFactoryValueReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), restoreFactoryValueReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-恢复出厂设置", a5Frame, commonFrame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-恢复出厂设置", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | if ("操作成功".equals(operationReportInnerFrame.getState())) { |
| | | //恢复出厂设置成功,需要修改C3Mac地址 |
| | | c3mCharging.setC3Mac("00000000"); |
| | | updateById(c3mCharging); |
| | | one.setC3Mac("00000000"); |
| | | updateById(one); |
| | | } |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | |
| | | /** |
| | | * 软重启 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String restartCharging(String c3Mac) { |
| | | public String restartCharging(Long c3Id) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | |
| | | C3RestartChargingReqInnerFrame c3RestartChargingReqInnerFrame = |
| | | new C3RestartChargingReqInnerFrame(c3Mac); |
| | | new C3RestartChargingReqInnerFrame(one.getC3Mac()); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3RestartChargingReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-软重启", a5Frame, commonFrame); |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-软重启", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |