| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import cn.hutool.core.util.PageUtil; |
| | | 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.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.config.C3mRedisConfig; |
| | | import com.sandu.ximon.admin.controller.C3mChargingChargeController; |
| | | 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.param.C3ChargingAddParam; |
| | | import com.sandu.ximon.admin.param.C3ChargingParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.ListPagingUtils; |
| | | import com.sandu.ximon.admin.utils.LogUtils; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | public List<C3ChargingBo> getC3ChargingListByKeyword(BaseConditionVO baseConditionVO, C3ChargingParam c3ChargingParam) { |
| | | if (baseConditionVO != null) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | } |
| | | public Map getC3ChargingListByKeyword(BaseConditionVO baseConditionVO, C3ChargingParam c3ChargingParam) { |
| | | if (c3ChargingParam == null) { |
| | | c3ChargingParam = new C3ChargingParam(); |
| | | } |
| | |
| | | } else { |
| | | c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword(), SecurityUtils.getUserId()); |
| | | } |
| | | //在线数量 |
| | | 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); |
| | | } else { |
| | | c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(null, SecurityUtils.getUserId()); |
| | | } |
| | | for (C3ChargingBo one : c3ChargingBoList) { |
| | | String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac()); |
| | | if (s != null) { |
| | |
| | | } else { |
| | | one.setStatusBit(0); |
| | | } |
| | | |
| | | } |
| | | return c3ChargingBoList; |
| | | } |
| | |
| | | chargingDto.setDeviceTemperature(beatDataPackage.getDeviceTemperature()); |
| | | //灯杆ID |
| | | chargingDto.setPoleId(pole.getId()); |
| | | //费率 |
| | | BigDecimal bigDecimal = SpringContextHolder.getBean(C3mChargingChargeService.class).getchargeDecimalByC3id(one.getC3Id()); |
| | | chargingDto.setRate(bigDecimal); |
| | | } |
| | | |
| | | return chargingDto; |
| | |
| | | |
| | | 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()) { |
| | |
| | | } else { |
| | | throw new BusinessException("数据校验错误,请重新请求"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |