| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.domain.CommonPage; |
| | |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.config.C3mRedisConfig; |
| | | import com.sandu.ximon.admin.dto.ChargingDto; |
| | | import com.sandu.ximon.admin.dto.TerminalDto; |
| | | import com.sandu.ximon.admin.manager.iot.frame.A5Frame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3HeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3OperationReportInnerFrame; |
| | |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.C3mRedisConstant; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.util.SupplementUtils; |
| | | import com.sandu.ximon.admin.param.C3ChargingAddParam; |
| | | import com.sandu.ximon.admin.param.C3ChargingParam; |
| | | import com.sandu.ximon.admin.redis.DeviceRedisKey; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.*; |
| | | import com.sandu.ximon.admin.vo.EquipmentInfomation; |
| | | import com.sandu.ximon.admin.vo.RedisDeviceStatus; |
| | | import com.sandu.ximon.dao.bo.C3ChargingBo; |
| | | import com.sandu.ximon.dao.domain.*; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import com.sandu.ximon.dao.enums.OrderStatus; |
| | | import com.sandu.ximon.dao.mapper.C3mChargingMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author ZZQ |
| | |
| | | @Slf4j |
| | | @AllArgsConstructor |
| | | public class C3ChargingService extends BaseServiceImpl<C3mChargingMapper, C3mCharging> { |
| | | private C3mChargingMapper c3mChargingMapper; |
| | | private final C3mChargingMapper c3mChargingMapper; |
| | | private final C3mChargingChargeService c3mChargingChargeService; |
| | | private final PoleBindingService bindingService; |
| | | private final PoleService poleService; |
| | | private final RedisUtils redisUtils; |
| | | |
| | | /** |
| | | * 保存上报C3充电设备心跳数据 |
| | |
| | | * @return 是否成功 |
| | | */ |
| | | public boolean updateReportState(String deviceName, String c3Mac, String statusBit, String deviceTemperature) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac)); |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (one != null) { |
| | | one.setDeviceTemperature(deviceTemperature); |
| | | one.setPoleDevicesCode(deviceName); |
| | |
| | | * |
| | | * @return 是否成功 |
| | | */ |
| | | @SneakyThrows |
| | | public boolean saveReporEquipment(String deviceName, String mcuUdid, String c3Mac) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid)); |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid).last("limit 1")); |
| | | boolean flag; |
| | | if (one == null) { |
| | | //将设备信息添加到充电桩设备表 |
| | |
| | | flag = updateById(one); |
| | | } |
| | | |
| | | String newC3Mac = c3Mac; |
| | | /** |
| | | * 初始化c3mac地址开始 |
| | | */ |
| | | if (c3Mac.equals("00000000")) { |
| | | System.out.println("初始化c3mac地址开始"); |
| | | List<C3mCharging> list = list(); |
| | | //从list集合中,取出字段name的列表并去重 |
| | | List<String> c3macList = list.stream().map(C3mCharging::getC3Mac).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList()); |
| | | for (int index = 1; true; index++) { |
| | | newC3Mac = SupplementUtils.suppleZero(index, 8); |
| | | if (!c3macList.contains(newC3Mac)) { |
| | | //失败重发一次 |
| | | String s = SetAddress(one.getC3Id(), newC3Mac, true); |
| | | if (!"操作成功".equals(s)) { |
| | | LogUtils.error("初始化充电桩失败!"); |
| | | return false; |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | System.out.println("初始化c3mac地址结束"); |
| | | } |
| | | |
| | | /** |
| | | * 初始化c3mac地址结束 |
| | | */ |
| | | |
| | | |
| | | //同步时间戳 |
| | | System.out.println("同步时间戳开始"); |
| | | String date = new SimpleDateFormat("yyMMddHHmmss").format(new Date()); |
| | | String s = SetCalendar(c3Mac, 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))); |
| | | Integer.parseInt(date.substring(8, 10)), Integer.parseInt(date.substring(10, 12)), true); |
| | | if (!"操作成功".equals(s)) { |
| | | LogUtils.error("发送设置C3时间同步失败!"); |
| | | return false; |
| | | } |
| | | System.out.println("同步时间戳结束"); |
| | | |
| | | Thread.sleep(1000); |
| | | |
| | | //设置费率 |
| | | System.out.println("设置费率开始"); |
| | | C3mCharging c3mCharging1 = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid)); |
| | | C3mCharging c3mCharging1 = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid).last("limit 1")); |
| | | List<C3mChargingCharge> list = c3mChargingChargeService.list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, c3mCharging1.getC3Id())); |
| | | if (list.size() == 0) {//费率表中没有此充电桩数据时 添加默认费率 |
| | | c3mChargingChargeService.initCharge((c3mCharging1.getC3Id()).intValue()); |
| | | } |
| | | String rateState = setRate(c3Mac, list); |
| | | String rateState = setRate(newC3Mac, list, true); |
| | | System.out.println("设置费率结果:" + rateState); |
| | | System.out.println("设置费率结束"); |
| | | |
| | | Thread.sleep(1000); |
| | | |
| | | |
| | | /** 跳包时间同步 |
| | | * 设置时间规则:充电时为1倍,非充电状态为1.5倍时间 |
| | |
| | | Set<String> keys = RedisUtils.getBean().keys(C3mRedisConstant.C3_STATUS.getCode() + "*"); |
| | | |
| | | C3mRedisConfig.reFlushTime(keys.size()); |
| | | String time1 = SetHeartbeatPacketTimeCharging(c3Mac, C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME) * 2, false); |
| | | String time1 = SetHeartbeatPacketTimeCharging(one.getC3Id(), C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME) * 2, false, true); |
| | | LogUtils.error("C3空闲心跳包时间同步响应结果:" + time1); |
| | | String time2 = SetHeartbeatPacketTimeCharging(c3Mac, C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME), true); |
| | | String time2 = SetHeartbeatPacketTimeCharging(one.getC3Id(), C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME), true, true); |
| | | LogUtils.error("C3充电时心跳包时间同步响应结果:" + time2); |
| | | System.out.println("设置心跳包间隔时间结束"); |
| | | |
| | | Thread.sleep(1000); |
| | | |
| | | /** |
| | | * 获取心跳包,判断在线 |
| | | */ |
| | | System.out.println("获取心跳包开始"); |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = ReadTheHeartbeatPackage(c3Mac); |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = ReadTheHeartbeatPackage(one.getC3Id(), true); |
| | | if (aPackage == null) { |
| | | LogUtils.error("读取心跳包为空"); |
| | | return false; |
| | | } |
| | | RedisUtils redisUtils = RedisUtils.getBean(); |
| | | redisUtils.set( |
| | | C3mRedisConstant.C3_STATUS.getCode() + c3Mac, |
| | | C3mRedisConstant.C3_STATUS.getCode() + newC3Mac, |
| | | JSON.toJSONString(aPackage), |
| | | C3mRedisConfig.OUTLINE_TIME |
| | | ); |
| | | System.out.println("获取心跳包结束"); |
| | | Thread.sleep(1000); |
| | | |
| | | /** |
| | | * 是否有进行中的个订单 |
| | | */ |
| | | SpringContextHolder.getBean(C3mOrderService.class).stopCharingOrder(aPackage); |
| | | |
| | | |
| | | /** |
| | | * finally、同步结束 |
| | | */ |
| | | System.out.println("同步结束 开始"); |
| | | String end = EndOfTheSynchronization(c3Mac); |
| | | String end = EndOfTheSynchronization(newC3Mac, true); |
| | | if (!"操作成功".equals(end)) { |
| | | LogUtils.error("C3同步结束响应结果" + end); |
| | | return false; |
| | |
| | | int faultNumber = 0; |
| | | //等待接入数量 |
| | | int waitConnectNumber = 0; |
| | | //充电中数量 |
| | | int chargingNumber = 0; |
| | | |
| | | for (C3ChargingBo one : c3ChargingBoList) { |
| | | String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac()); |
| | |
| | | break; |
| | | //2.充电中 |
| | | case 2: |
| | | chargingNumber++; |
| | | onlineNumber = onlineNumber + 1; |
| | | break; |
| | | //3.充电中断,等待服务器确认 |
| | |
| | | map.put("offlineNumber", offlineNumber); |
| | | map.put("faultNumber", faultNumber); |
| | | map.put("waitConnectNumber", waitConnectNumber); |
| | | map.put("chargingNumber", chargingNumber); |
| | | |
| | | return map; |
| | | } |
| | |
| | | throw new BusinessException("充电桩绑定的灯杆不存在!"); |
| | | } |
| | | |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getPoleDevicesCode, pole.getDeviceCode())); |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getPoleDevicesCode, pole.getDeviceCode()).last("limit 1")); |
| | | ChargingDto chargingDto = new ChargingDto(); |
| | | |
| | | if (one == null) { |
| | | throw new BusinessException("充电桩信息不存在!"); |
| | | } |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = ReadTheHeartbeatPackage(one.getC3Mac()); |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = ReadTheHeartbeatPackage(one.getC3Id(), false); |
| | | if (beatDataPackage != null) { |
| | | //充电桩ID |
| | | chargingDto.setC3Id(one.getC3Id()); |
| | |
| | | chargingDto.setPoleId(pole.getId()); |
| | | //费率 |
| | | BigDecimal bigDecimal = SpringContextHolder.getBean(C3mChargingChargeService.class).getchargeDecimalByC3id(one.getC3Id()); |
| | | //已充电量 |
| | | chargingDto.setChargedCapacity(beatDataPackage.getChargedCapacity()); |
| | | //充电时长 |
| | | chargingDto.setAlreadyChargingTime(beatDataPackage.getAlreadyChargingTime()); |
| | | chargingDto.setRate(bigDecimal); |
| | | } |
| | | |
| | |
| | | if (udid == null || udid.trim().length() == 0) { |
| | | return equipmentInfo; |
| | | } |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, udid)); |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, udid).last("limit 1")); |
| | | if (one != null) { |
| | | String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac()); |
| | | if (s != null) { |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3StartChargingReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac)); |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 结束充电 |
| | | * |
| | | * @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("充电桩没有进行中的订单"); |
| | | } |
| | | if (!openId.equals(order.getOrderId())) { |
| | | if (!openId.equals(order.getUserCode())) { |
| | | 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)); |
| | | 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 |
| | | * @param resendFlag 重发标志 |
| | | */ |
| | | public String EndOfTheSynchronization(String c3Mac) { |
| | | public String EndOfTheSynchronization(String c3Mac, boolean resendFlag) { |
| | | C3EndOfTheSynchronizationReqInnerFrame c3EndOfTheSynchronizationReqInnerFrame = |
| | | new C3EndOfTheSynchronizationReqInnerFrame(c3Mac); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3EndOfTheSynchronizationReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac)); |
| | | 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); |
| | | CommonFrame commonFrame; |
| | | if (resendFlag) { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-同步结束", a5Frame, commonFrame); |
| | | |
| | | |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QrCodeReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac)); |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac).last("limit 1")); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 查询版本 |
| | | * |
| | | * @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)); |
| | | 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)); |
| | | 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)); |
| | | 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)); |
| | | 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)); |
| | | 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) { |
| | | 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)); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | CommonFrame commonFrame; |
| | | if (resendFlag) { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.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) { |
| | | 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)); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | CommonFrame commonFrame; |
| | | if (resndFlag) { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.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)); |
| | | 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) { |
| | | public String SetAddress(Long c3Id, String address, boolean resendFlag) { |
| | | C3mCharging one = getById(c3Id); |
| | | if (one == null) { |
| | | System.out.println("充电桩不存在!"); |
| | | } |
| | | |
| | | if (address == null || address.length() != 8) { |
| | | throw new BusinessException("地址信息错误!"); |
| | | } |
| | | |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac)); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3MAC地址不存在"); |
| | | } |
| | | |
| | | if (getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, address)) != null) { |
| | | if (getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, address).last("limit 1")) != null) { |
| | | throw new BusinessException("新的地址信息已存在!"); |
| | | } |
| | | |
| | | 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 = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置地址", a5Frame, commonFrame); |
| | | CommonFrame commonFrame; |
| | | if (resendFlag) { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | 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)); |
| | | 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) { |
| | | |
| | | 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)); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | CommonFrame commonFrame; |
| | | if (resendFlag) { |
| | | //需要重发 |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | //不需要重发 |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(one.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置日历", a5Frame, commonFrame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(one.getC3Mac(), "C3帧-设置日历", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public String setRate(String c3Mac, List<C3mChargingCharge> list) { |
| | | public String setRate(String c3Mac, List<C3mChargingCharge> list, boolean resendFlag) { |
| | | if (StringUtil.strIsNullOrEmpty(c3Mac)) { |
| | | throw new BusinessException("C3Mac地址不能为空!"); |
| | | } |
| | |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3SetRateReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | C3mCharging c3mCharging = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac)); |
| | | 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); |
| | | CommonFrame commonFrame; |
| | | if (resendFlag) { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame, true); |
| | | } else { |
| | | commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | } |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "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)); |
| | | 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)); |
| | | 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()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | if ("操作成功".equals(operationReportInnerFrame.getState())) { |
| | | //恢复出厂设置成功,需要修改C3Mac地址 |
| | | one.setC3Mac("00000000"); |
| | | updateById(one); |
| | | } |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | |
| | | |
| | | /** |
| | | * 软重启 |
| | | * |
| | | * @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)); |
| | | 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"); |
| | |
| | | } |
| | | |
| | | public boolean addC3Charging(C3ChargingAddParam c3ChargingAddParam) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, c3ChargingAddParam.getMcuUdid())); |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, c3ChargingAddParam.getMcuUdid()).last("limit 1")); |
| | | if (one != null) { |
| | | throw new BusinessException("硬件设备已存在!"); |
| | | } |
| | |
| | | * 添加充电桩 日志记录结束 |
| | | */ |
| | | |
| | | return |
| | | |
| | | save(c3mCharging); |
| | | return save(c3mCharging); |
| | | |
| | | } |
| | | |
| | | public boolean updateC3ChargingName(C3ChargingAddParam c3ChargingAddParam) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Id, c3ChargingAddParam.getC3Id())); |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Id, c3ChargingAddParam.getC3Id()).last("limit 1")); |
| | | if (one == null) { |
| | | throw new BusinessException("硬件设备不存在!"); |
| | | } |
| | |
| | | if (one == null) { |
| | | throw new BusinessException("未找到绑定关系"); |
| | | } |
| | | return getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, one.getDeviceCode())); |
| | | return getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, one.getDeviceCode()).last("limit 1")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 向Redis中存入设备状态 |
| | | */ |
| | | public void setCacheData() { |
| | | list().forEach( |
| | | device -> { |
| | | RedisDeviceStatus deviceStatus = new RedisDeviceStatus(); |
| | | deviceStatus.setDeviceId(device.getC3Id().toString()); |
| | | if (device != null) { |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = ReadTheHeartbeatPackage(device.getC3Id(), false); |
| | | if (beatDataPackage != null) { |
| | | //在线状态 1.空闲 2.充电中 3.充电中断,等待服务器确认 4.充电结束,等待服务器确认 5.有故障 6.与充电桩对接中 |
| | | deviceStatus.setStatus(Integer.valueOf(beatDataPackage.getStatusBit())); |
| | | |
| | | }else{ |
| | | |
| | | } |
| | | } |
| | | redisUtils.set(DeviceRedisKey.IP_BROADCAST + device.getC3Id(), deviceStatus); |
| | | } |
| | | ); |
| | | |
| | | } |
| | | } |