| | |
| | | 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.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.CommonPage; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.manager.iot.amqp.processor.c3ChargingProcessor; |
| | | 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.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.frame.inner.request.*; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.C3ChargingEnum; |
| | | 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.utils.RedisUtils; |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.dao.domain.C3mChargingCharge; |
| | | import com.sandu.ximon.admin.param.C3ChargingAddParam; |
| | | import com.sandu.ximon.admin.param.C3ChargingParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.*; |
| | | import com.sandu.ximon.admin.vo.EquipmentInfomation; |
| | | 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.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author ZZQ |
| | |
| | | @Slf4j |
| | | @AllArgsConstructor |
| | | public class C3ChargingService extends BaseServiceImpl<C3mChargingMapper, C3mCharging> { |
| | | |
| | | private C3mChargingMapper c3mChargingMapper; |
| | | private final C3mChargingChargeService c3mChargingChargeService; |
| | | private final PoleBindingService bindingService; |
| | | private final PoleService poleService; |
| | | |
| | | /** |
| | | * 保存上报C3充电设备心跳数据 |
| | | * |
| | | * @return 是否成功 |
| | | */ |
| | | public boolean saveReportData(String deviceName, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, deviceName)); |
| | | List<C3mChargingCharge> list = c3mChargingChargeService.list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, one.getC3Id())); |
| | | if(list.size()==0){//费率表中没有此充电桩数据时 添加默认费率 |
| | | c3mChargingChargeService.initCharge((one.getC3Id()).intValue()); |
| | | public boolean updateReportState(String deviceName, String c3Mac, String statusBit, String deviceTemperature) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, c3Mac)); |
| | | if (one != null) { |
| | | one.setDeviceTemperature(deviceTemperature); |
| | | one.setPoleDevicesCode(deviceName); |
| | | one.setC3Mac(c3Mac); |
| | | return updateById(one); |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存上报C3充电设备 |
| | | * |
| | | * @return 是否成功 |
| | | */ |
| | | public boolean saveReporEquipment(String deviceName, String mcuUdid, String c3Mac) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid)); |
| | | boolean flag; |
| | | if (one == null) { |
| | | //将设备信息添加到充电桩设备表 |
| | | C3mCharging c3mCharging = new C3mCharging(); |
| | | c3mCharging.setMcuUdid(deviceName); |
| | | c3mCharging.setC3Mac(heartBeatDataPackage.getC3Mac()); |
| | | c3mCharging.setStatusBit(Integer.valueOf(heartBeatDataPackage.getStatusBit())); |
| | | c3mCharging.setDeviceTemperature(heartBeatDataPackage.getDeviceTemperature()); |
| | | return save(c3mCharging); |
| | | c3mCharging.setMcuUdid(mcuUdid); |
| | | c3mCharging.setPoleDevicesCode(deviceName); |
| | | c3mCharging.setC3Mac(c3Mac); |
| | | flag = save(c3mCharging); |
| | | } else { |
| | | one.setStatusBit(Integer.valueOf(heartBeatDataPackage.getStatusBit())); |
| | | one.setDeviceTemperature(heartBeatDataPackage.getDeviceTemperature()); |
| | | return updateById(one); |
| | | //将设备信息添加到充电桩设备表 |
| | | one.setPoleDevicesCode(deviceName); |
| | | one.setC3Mac(c3Mac); |
| | | flag = updateById(one); |
| | | } |
| | | |
| | | //同步时间戳 |
| | | 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)), |
| | | Integer.parseInt(date.substring(4, 6)), Integer.parseInt(date.substring(6, 8)), |
| | | Integer.parseInt(date.substring(8, 10)), Integer.parseInt(date.substring(10, 12))); |
| | | if (!"操作成功".equals(s)) { |
| | | LogUtils.error("发送设置C3时间同步失败!"); |
| | | return false; |
| | | } |
| | | System.out.println("同步时间戳结束"); |
| | | |
| | | //设置费率 |
| | | System.out.println("设置费率开始"); |
| | | C3mCharging c3mCharging1 = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, mcuUdid)); |
| | | 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); |
| | | System.out.println("设置费率结果:" + rateState); |
| | | System.out.println("设置费率结束"); |
| | | |
| | | /** 跳包时间同步 |
| | | * 设置时间规则:充电时为1倍,非充电状态为1.5倍时间 |
| | | */ |
| | | System.out.println("设置心跳包间隔时间开始"); |
| | | 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); |
| | | LogUtils.error("C3空闲心跳包时间同步响应结果:" + time1); |
| | | String time2 = SetHeartbeatPacketTimeCharging(c3Mac, C3mRedisConfig.parseInt(C3mRedisConfig.HEART_BEAT_TIME), true); |
| | | LogUtils.error("C3充电时心跳包时间同步响应结果:" + time2); |
| | | System.out.println("设置心跳包间隔时间结束"); |
| | | |
| | | |
| | | /** |
| | | * 获取心跳包,判断在线 |
| | | */ |
| | | System.out.println("获取心跳包开始"); |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage aPackage = ReadTheHeartbeatPackage(c3Mac); |
| | | if (aPackage == null) { |
| | | LogUtils.error("读取心跳包为空"); |
| | | return false; |
| | | } |
| | | RedisUtils redisUtils = RedisUtils.getBean(); |
| | | redisUtils.set( |
| | | C3mRedisConstant.C3_STATUS.getCode() + c3Mac, |
| | | JSON.toJSONString(aPackage), |
| | | C3mRedisConfig.OUTLINE_TIME |
| | | ); |
| | | System.out.println("获取心跳包结束"); |
| | | |
| | | /** |
| | | * finally、同步结束 |
| | | */ |
| | | System.out.println("同步结束 开始"); |
| | | String end = EndOfTheSynchronization(c3Mac); |
| | | if (!"操作成功".equals(end)) { |
| | | LogUtils.error("C3同步结束响应结果" + end); |
| | | return false; |
| | | } |
| | | System.out.println("同步结束 结束"); |
| | | |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | public List<C3mCharging> getC3ChargingList(BaseConditionVO baseConditionVO) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | return list(); |
| | | public Map getC3ChargingListByKeyword(BaseConditionVO baseConditionVO, C3ChargingParam c3ChargingParam, Integer order, Integer seq) { |
| | | if (c3ChargingParam == null) { |
| | | c3ChargingParam = new C3ChargingParam(); |
| | | } |
| | | |
| | | //关键字去除空格 |
| | | if (c3ChargingParam.getKeyword() != null) { |
| | | c3ChargingParam.setKeyword(c3ChargingParam.getKeyword().trim()); |
| | | } |
| | | //排序字段 |
| | | String orderByResult = "t1.c3_id"; |
| | | //正序、倒叙 |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.CHARGE_POLE_CREATE_TIME.getCode(); |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | if (seq != null) { |
| | | switch (seq) { |
| | | case 1: |
| | | orderBySeq = " ASC"; |
| | | break; |
| | | case 2: |
| | | orderBySeq = " DESC"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | //排序方式 |
| | | String orderBy = orderByResult + " " + orderBySeq; |
| | | |
| | | List<C3ChargingBo> c3ChargingBoList; |
| | | if (SecurityUtils.getClientId() == null) { |
| | | c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword(), null, orderBy); |
| | | } else { |
| | | c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword(), SecurityUtils.getUserId(), orderBy); |
| | | } |
| | | //在线数量 |
| | | int onlineNumber = 0; |
| | | //离线数量 |
| | | int offlineNumber = 0; |
| | | //故障数量 |
| | | int faultNumber = 0; |
| | | //等待接入数量 |
| | | int waitConnectNumber = 0; |
| | | |
| | | for (C3ChargingBo one : c3ChargingBoList) { |
| | | String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac()); |
| | | if (s != null) { |
| | | try { |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class); |
| | | one.setStatusBit((Integer.valueOf(beatDataPackage.getStatusBit()))); |
| | | switch (Integer.valueOf(beatDataPackage.getStatusBit())) { |
| | | //1.空闲 |
| | | case 1: |
| | | onlineNumber = onlineNumber + 1; |
| | | break; |
| | | //2.充电中 |
| | | case 2: |
| | | onlineNumber = onlineNumber + 1; |
| | | break; |
| | | //3.充电中断,等待服务器确认 |
| | | case 3: |
| | | onlineNumber = onlineNumber + 1; |
| | | break; |
| | | //4.充电结束,等待服务器确认 |
| | | case 4: |
| | | onlineNumber = onlineNumber + 1; |
| | | break; |
| | | //5.有故障 |
| | | case 5: |
| | | faultNumber = faultNumber + 1; |
| | | break; |
| | | //6.与充电桩对接中 |
| | | case 6: |
| | | waitConnectNumber = waitConnectNumber + 1; |
| | | break; |
| | | default: |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | offlineNumber = offlineNumber + 1; |
| | | } |
| | | } else { |
| | | one.setStatusBit(0); |
| | | offlineNumber = offlineNumber + 1; |
| | | } |
| | | |
| | | } |
| | | Map map = new LinkedHashMap(); |
| | | CommonPage commonPage = ListPagingUtils.pages(c3ChargingBoList, baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | map.put("pageNum", commonPage.getPageNum()); |
| | | map.put("pageSize", commonPage.getPageSize()); |
| | | map.put("totalPage", commonPage.getTotalPage()); |
| | | map.put("total", commonPage.getTotal()); |
| | | map.put("list", commonPage.getList()); |
| | | map.put("onlineNumber", onlineNumber); |
| | | map.put("offlineNumber", offlineNumber); |
| | | map.put("faultNumber", faultNumber); |
| | | map.put("waitConnectNumber", waitConnectNumber); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 首页统计充电桩列表数据 |
| | | * |
| | | * @return |
| | | */ |
| | | public List<C3ChargingBo> getC3ChargingList() { |
| | | |
| | | List<C3ChargingBo> c3ChargingBoList; |
| | | if (SecurityUtils.getClientId() == null) { |
| | | c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(null, null, "c3_id ASC"); |
| | | } else { |
| | | c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(null, SecurityUtils.getUserId(), "c3_id ASC"); |
| | | } |
| | | return c3ChargingBoList; |
| | | } |
| | | |
| | | /** |
| | | * 获取充电桩详情 |
| | | * |
| | | * @return |
| | | */ |
| | | public ChargingDto getChargingInfo(String poleId) { |
| | | if (poleId == null) { |
| | | throw new BusinessException("灯杆ID不能为空!"); |
| | | } |
| | | |
| | | Pole pole = SpringContextHolder.getBean(PoleService.class). |
| | | getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, poleId)); |
| | | if (pole == null) { |
| | | throw new BusinessException("充电桩绑定的灯杆不存在!"); |
| | | } |
| | | |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getPoleDevicesCode, pole.getDeviceCode())); |
| | | ChargingDto chargingDto = new ChargingDto(); |
| | | |
| | | if (one == null) { |
| | | throw new BusinessException("充电桩信息不存在!"); |
| | | } |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = ReadTheHeartbeatPackage(one.getC3Mac()); |
| | | if (beatDataPackage != null) { |
| | | //充电桩ID |
| | | chargingDto.setC3Id(one.getC3Id()); |
| | | //C3Mac |
| | | chargingDto.setC3Mac(one.getC3Mac()); |
| | | //在线状态 1.空闲 2.充电中 3.充电中断,等待服务器确认 4.充电结束,等待服务器确认 5.有故障 6.与充电桩对接中 |
| | | chargingDto.setStatusBit(Integer.valueOf(beatDataPackage.getStatusBit())); |
| | | //电压 |
| | | chargingDto.setGridVoltage(beatDataPackage.getGridVoltage()); |
| | | //电流 |
| | | chargingDto.setGridCurrent(beatDataPackage.getGridCurrent()); |
| | | //温度 |
| | | chargingDto.setDeviceTemperature(beatDataPackage.getDeviceTemperature()); |
| | | //灯杆ID |
| | | chargingDto.setPoleId(pole.getId()); |
| | | //费率 |
| | | BigDecimal bigDecimal = SpringContextHolder.getBean(C3mChargingChargeService.class).getchargeDecimalByC3id(one.getC3Id()); |
| | | chargingDto.setRate(bigDecimal); |
| | | } |
| | | |
| | | return chargingDto; |
| | | } |
| | | |
| | | /** |
| | | * 首页灯杆绑定信息 |
| | | * |
| | | * @return |
| | | */ |
| | | public EquipmentInfomation getByC3MacInfo(String udid) { |
| | | EquipmentInfomation equipmentInfo = new EquipmentInfomation(); |
| | | equipmentInfo.setEquipmentType("C3充电桩"); |
| | | if (udid == null || udid.trim().length() == 0) { |
| | | return equipmentInfo; |
| | | } |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, udid)); |
| | | if (one != null) { |
| | | String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac()); |
| | | if (s != null) { |
| | | try { |
| | | A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class); |
| | | switch (beatDataPackage.getStatusBit()) { |
| | | case "1": |
| | | equipmentInfo.setEquipmentState("空闲"); |
| | | break; |
| | | case "2": |
| | | equipmentInfo.setEquipmentState("充电中"); |
| | | break; |
| | | case "3": |
| | | equipmentInfo.setEquipmentState("充电中断,等待服务器确认"); |
| | | break; |
| | | case "4": |
| | | equipmentInfo.setEquipmentState("充电结束,等待服务器确认"); |
| | | break; |
| | | case "5": |
| | | equipmentInfo.setEquipmentState("有故障"); |
| | | break; |
| | | case "6": |
| | | equipmentInfo.setEquipmentState("与充电桩对接中"); |
| | | break; |
| | | default: |
| | | equipmentInfo.setEquipmentState("未知"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else { |
| | | equipmentInfo.setEquipmentState("离线"); |
| | | } |
| | | equipmentInfo.setEquipmentCreateTime(one.getUpdateTime()); |
| | | equipmentInfo.setEquipmentMac(one.getMcuUdid()); |
| | | equipmentInfo.setEquipmentName(one.getC3Name()); |
| | | } |
| | | return equipmentInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 开始充电 |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3StartChargingReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff0a04ffff", 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); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | |
| | |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String finishCharging(String c3Mac) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String finishCharging(String c3Mac, String openId) { |
| | | //查询 |
| | | 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")); |
| | | |
| | | if (order == null) { |
| | | throw new BusinessException("充电桩没有进行中的订单"); |
| | | } |
| | | if (!openId.equals(order.getOrderId())) { |
| | | throw new BusinessException("不能操作不属于您的订单"); |
| | | } |
| | | |
| | | C3FinishChargingReqInnerFrame c3FinishChargingReqInnerFrame = |
| | | new C3FinishChargingReqInnerFrame(c3Mac); |
| | | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3FinishChargingReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff0a04ffff", 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); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | //结束充电 更改订单状态 |
| | | C3mOrder lastOrderByC3Mac = SpringContextHolder.getBean(C3mOrderService.class).getLastOrderByC3Mac(c3Mac); |
| | | if (lastOrderByC3Mac != null) { |
| | | //设置订单状态为已完成 |
| | | lastOrderByC3Mac.setOrderStatus(OrderStatus.COMPLETE.getStatus()); |
| | | |
| | | BigDecimal actualChargingCapacity = BigDecimal.valueOf(lastOrderByC3Mac.getActualChargingCapacity()); |
| | | BigDecimal actualChargingCapacityHide = BigDecimal.valueOf(lastOrderByC3Mac.getActualChargingCapacityHide()); |
| | | //设置实际充电电量 |
| | | lastOrderByC3Mac.setActualChargingCapacity(actualChargingCapacity.add(actualChargingCapacityHide).doubleValue()); |
| | | //设置订单结束时间 |
| | | lastOrderByC3Mac.setStopChargingTimestamp(System.currentTimeMillis()); |
| | | lastOrderByC3Mac.setActualChargingCapacity(0.00); |
| | | //设置订单状态为充电结束 |
| | | lastOrderByC3Mac.setChargingStates(1); |
| | | SpringContextHolder.getBean(C3mOrderService.class).updateById(lastOrderByC3Mac); |
| | | } |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3EndOfTheSynchronizationReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff0a04ffff", 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); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 二维码 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String QrCode(String c3Mac, String qrCodeData) { |
| | | C3QrCodeReqInnerFrame c3QrCodeReqInnerFrame = new C3QrCodeReqInnerFrame(c3Mac, qrCodeData); |
| | | |
| | | 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)); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-二维码", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryVersionReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff0a04ffff", 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); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3QueryReportInnerFrame a5C3QueryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryIntervalTimeReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff0a04ffff", 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryConstantReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff0a04ffff", 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); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3QueryAddressReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff0a04ffff", 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); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | if (queryReportInnerFrame.isValidate()) { |
| | | return queryReportInnerFrame.getAddress(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询故障码 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public String QueryFaultCode(String c3Mac) { |
| | | C3QueryFaultCodeReqInnerFrame c3QueryFaultCodeReqInnerFrame = |
| | | new C3QueryFaultCodeReqInnerFrame(c3Mac); |
| | | |
| | | 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); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | if (queryReportInnerFrame.isValidate()) { |
| | | return queryReportInnerFrame.getFaultCode(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读心跳包 |
| | | * |
| | | * @param c3Mac |
| | | */ |
| | | public A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage ReadTheHeartbeatPackage(String c3Mac) { |
| | | C3ReadTheHeartbeatPackageReqInnerFrame readTheHeartbeatPackageReqInnerFrame = |
| | | new C3ReadTheHeartbeatPackageReqInnerFrame(c3Mac); |
| | | |
| | | 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 = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-读取心跳包", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3HeartbeatReportInnerFrame heartbeatReportInnerFrame = new A5C3HeartbeatReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (heartbeatReportInnerFrame.isValidate()) { |
| | | return heartbeatReportInnerFrame.getHeartBeatDataPackage(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置心跳包间隔时间(秒)-充电状态时/非充电状态时 |
| | | * |
| | | * @param c3Mac |
| | | * @param setTime |
| | | * @return |
| | | */ |
| | | public String SetHeartbeatPacketTimeCharging(String c3Mac, int setTime, boolean flag) { |
| | | if (setTime <= 0) { |
| | | throw new BusinessException("设置的心跳包间隔时间错误!"); |
| | | } |
| | | C3SetHeartbeatPacketTimeReqInnerFrame setHeartbeatPacketTimeChargingReqInnerFrame = |
| | | new C3SetHeartbeatPacketTimeReqInnerFrame(c3Mac, 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 = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置心跳包间隔时间", a5Frame, commonFrame); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置电压/电流常数(各一字节)(默认值0xBC64) |
| | | * |
| | | * @param c3Mac |
| | | * @param constant |
| | | * @return |
| | | */ |
| | | public String SetConstant(String c3Mac, String constant) { |
| | | |
| | | C3SetConstantReqInnerFrame setConstantReqInnerFrame = |
| | | new C3SetConstantReqInnerFrame(c3Mac, 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); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置地址 |
| | | * |
| | | * @param c3Mac |
| | | * @param address |
| | | * @return |
| | | */ |
| | | public String SetAddress(String c3Mac, String address) { |
| | | 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) { |
| | | throw new BusinessException("新的地址信息已存在!"); |
| | | } |
| | | |
| | | C3SetAddressReqInnerFrame setAddressReqInnerFrame = |
| | | new C3SetAddressReqInnerFrame(c3Mac, 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); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | //保存操作日志 |
| | | String content = "旧C3Mac地址:" + c3Mac + ";新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)); |
| | | one.setC3Mac(address); |
| | | updateById(one); |
| | | } |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 设置日历(同心跳包中的6字节日期时间) |
| | | * |
| | | * @param c3Mac |
| | | * @return |
| | | */ |
| | | public String SetCalendar(String c3Mac, int year, int month, int day, int hour, int min, int sec) { |
| | | |
| | | |
| | | C3SetCalendarReqInnerFrame setCalendarReqInnerFrame = |
| | | new C3SetCalendarReqInnerFrame(c3Mac, 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 = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置日历", a5Frame, commonFrame); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置费率 |
| | | * |
| | | * @param c3Mac |
| | | * @param list |
| | | * @return |
| | | */ |
| | | public String setRate(String c3Mac, List<C3mChargingCharge> list) { |
| | | if (StringUtil.strIsNullOrEmpty(c3Mac)) { |
| | | throw new BusinessException("C3Mac地址不能为空!"); |
| | | } |
| | | if (list.isEmpty()) { |
| | | throw new BusinessException("费率数据不能为空!"); |
| | | } |
| | | C3SetRateReqInnerFrame c3SetRateReqInnerFrame = new C3SetRateReqInnerFrame(c3Mac, list); |
| | | |
| | | 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)); |
| | | if (c3mCharging == null) { |
| | | throw new BusinessException("C3充电桩硬件mcu_udid不存在"); |
| | | } |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame); |
| | | StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3帧-设置费率", a5Frame, commonFrame); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 故障码上报清除 |
| | | * |
| | | * @param c3Mac |
| | | * @return |
| | | */ |
| | | public String ClearedFaultCode(String c3Mac) { |
| | | |
| | | |
| | | C3ClearedFaultCodeReqInnerFrame clearedFaultCodeReqInnerFrame = |
| | | new C3ClearedFaultCodeReqInnerFrame(c3Mac); |
| | | |
| | | 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 恢复出厂值 |
| | | * |
| | | * @param c3Mac |
| | | * @return |
| | | */ |
| | | public String RestoreFactoryValue(String c3Mac) { |
| | | |
| | | |
| | | C3RestoreFactoryValueReqInnerFrame restoreFactoryValueReqInnerFrame = |
| | | new C3RestoreFactoryValueReqInnerFrame(c3Mac); |
| | | |
| | | 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | |
| | | A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_C3_DATA.getCode(), c3RestartChargingReqInnerFrame); |
| | | System.out.println(a5Frame + " -----a5Frame"); |
| | | |
| | | CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff0a04ffff", 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); |
| | | |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | } |
| | | |
| | | public boolean addC3Charging(C3ChargingAddParam c3ChargingAddParam) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, c3ChargingAddParam.getMcuUdid())); |
| | | if (one != null) { |
| | | throw new BusinessException("硬件设备已存在!"); |
| | | } |
| | | |
| | | if (c3ChargingAddParam.getC3Name() == null || c3ChargingAddParam.getMcuUdid() == null) { |
| | | throw new BusinessException("添加C3充电桩设备出错!"); |
| | | } |
| | | C3mCharging c3mCharging = new C3mCharging(); |
| | | c3mCharging.setMcuUdid(c3ChargingAddParam.getMcuUdid()); |
| | | if (c3ChargingAddParam.getC3Name() != null) { |
| | | c3mCharging.setC3Name(c3ChargingAddParam.getC3Name()); |
| | | } |
| | | c3mCharging.setC3Mac(c3ChargingAddParam.getC3Mac()); |
| | | /** |
| | | * 添加充电桩 日志记录开始 |
| | | */ |
| | | List<String> listCode = new ArrayList<>(1); |
| | | listCode.add(c3mCharging.getMcuUdid()); |
| | | String content = "{设备code:" + c3mCharging.getMcuUdid() + "设备名:" + c3mCharging.getC3Name() + |
| | | "}"; |
| | | |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "添加充电桩", content); |
| | | /** |
| | | * 添加充电桩 日志记录结束 |
| | | */ |
| | | |
| | | return |
| | | |
| | | save(c3mCharging); |
| | | |
| | | } |
| | | |
| | | public boolean updateC3ChargingName(C3ChargingAddParam c3ChargingAddParam) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Id, c3ChargingAddParam.getC3Id())); |
| | | if (one == null) { |
| | | throw new BusinessException("硬件设备不存在!"); |
| | | } |
| | | |
| | | if (c3ChargingAddParam.getC3Id() == null || c3ChargingAddParam.getC3Name() == null) { |
| | | throw new BusinessException("添加C3充电桩设备出错!"); |
| | | } |
| | | C3mCharging c3mCharging = new C3mCharging(); |
| | | c3mCharging.setC3Id(c3ChargingAddParam.getC3Id()); |
| | | c3mCharging.setC3Name(c3ChargingAddParam.getC3Name()); |
| | | |
| | | /** |
| | | * 修改充电桩 日志记录开始 |
| | | */ |
| | | List<String> listCode = new ArrayList<>(1); |
| | | listCode.add(c3mCharging.getMcuUdid()); |
| | | String content = "{设备code:" + c3mCharging.getMcuUdid() + "设备原名:" + one.getC3Name() + "更改后的设备名:" + c3mCharging.getC3Name() + |
| | | "}"; |
| | | |
| | | StoreOperationRecordsUtils.storeOperationData(listCode, null, "编辑充电桩", content); |
| | | /** |
| | | * 修改充电桩 日志记录结束 |
| | | */ |
| | | |
| | | |
| | | return updateById(c3mCharging); |
| | | } |
| | | |
| | | public C3mCharging getC3mByPoleId(Long poleId) { |
| | | PoleBinding one = bindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceType, 2).eq(PoleBinding::getPoleId, poleId)); |
| | | if (one == null) { |
| | | throw new BusinessException("未找到绑定关系"); |
| | | } |
| | | return getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, one.getDeviceCode())); |
| | | } |
| | | |
| | | |
| | | } |