| | |
| | | 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.ximon.dao.bo.C3ChargingBo; |
| | | 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.report.A5C3QueryReportInnerFrame; |
| | | 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.mainboard.MainBoardInvokeSyncService; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.admin.param.C3ChargingAddParam; |
| | | import com.sandu.ximon.admin.param.C3ChargingParam; |
| | | import com.sandu.ximon.dao.domain.*; |
| | | import com.sandu.ximon.dao.mapper.C3mChargingMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @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)); |
| | | public boolean updateReportState(String deviceName, String c3Mac, String statusBit, String deviceTemperature) { |
| | | C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getPoleDevicesCode, deviceName)); |
| | | if (one != null) { |
| | | one.setStatusBit(Integer.valueOf(statusBit)); |
| | | one.setDeviceTemperature(deviceTemperature); |
| | | one.setPoleDevicesCode(deviceName); |
| | | one.setC3Mac(c3Mac); |
| | | |
| | | // List<C3mChargingCharge> list = c3mChargingChargeService.list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, one.getC3Id())); |
| | | // if (list.size() == 0) {//费率表中没有此充电桩数据时 添加默认费率 |
| | | // c3mChargingChargeService.initCharge((one.getC3Id()).intValue()); |
| | | // } |
| | | 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)); |
| | | 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); |
| | | boolean flag = save(c3mCharging); |
| | | //设置费率 |
| | | 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()); |
| | | } |
| | | |
| | | return flag; |
| | | } else { |
| | | one.setStatusBit(Integer.valueOf(heartBeatDataPackage.getStatusBit())); |
| | | one.setDeviceTemperature(heartBeatDataPackage.getDeviceTemperature()); |
| | | return updateById(one); |
| | | //将设备信息添加到充电桩设备表 |
| | | one.setPoleDevicesCode(deviceName); |
| | | one.setC3Mac(c3Mac); |
| | | boolean flag = updateById(one); |
| | | //设置费率 |
| | | 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()); |
| | | } |
| | | |
| | | return flag; |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | public List<C3mCharging> getC3ChargingList(BaseConditionVO baseConditionVO) { |
| | | public List<C3ChargingBo> getC3ChargingListByKeyword(BaseConditionVO baseConditionVO, C3ChargingParam c3ChargingParam) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | return list(); |
| | | if(c3ChargingParam == null){ |
| | | c3ChargingParam = new C3ChargingParam(); |
| | | } |
| | | |
| | | //关键字去除空格 |
| | | if (c3ChargingParam.getKeyword() != null) { |
| | | c3ChargingParam.setKeyword(c3ChargingParam.getKeyword().trim()); |
| | | } |
| | | |
| | | List<C3ChargingBo> c3ChargingBoList |
| | | = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword()); |
| | | return c3ChargingBoList; |
| | | } |
| | | |
| | | /** |
| | |
| | | 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); |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | |
| | |
| | | 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | |
| | | 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); |
| | | |
| | | 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | //payload=FE10000800000042010C010CFD913F7D |
| | | A5C3QueryReportInnerFrame a5C3QueryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | if (a5C3QueryReportInnerFrame.isValidate()) { |
| | | return a5C3QueryReportInnerFrame.getVersion(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | |
| | | 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | if (queryReportInnerFrame.isValidate()) { |
| | | return queryReportInnerFrame.getIntervalTime(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | |
| | | 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | A5C3QueryReportInnerFrame queryReportInnerFrame = new A5C3QueryReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | if (queryReportInnerFrame.isValidate()) { |
| | | return queryReportInnerFrame.getConstant(); |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | |
| | | 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); |
| | | |
| | | 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); |
| | | |
| | | 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); |
| | | |
| | | 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); |
| | | |
| | | 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); |
| | | |
| | | 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | 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); |
| | | |
| | | 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); |
| | | |
| | | 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); |
| | | |
| | | System.out.println(commonFrame + " -----commonFrame"); |
| | | |
| | | A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload()); |
| | | if (operationReportInnerFrame.isValidate()) { |
| | | return operationReportInnerFrame.getState(); |
| | | } else { |
| | |
| | | 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); |
| | | // CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff1a06ffff", a5Frame); |
| | | |
| | | 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()); |
| | | 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()); |
| | | 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::getC3Mac, one.getDeviceCode())); |
| | | } |
| | | } |