| | |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.integration.api.feignClient.IotInterfaceClient; |
| | | import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient; |
| | | import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; |
| | | import com.ruoyi.integration.api.vo.AddDevice; |
| | | import com.ruoyi.integration.api.vo.AddDeviceResp; |
| | | import com.ruoyi.integration.api.vo.DeleteDeviceResp; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | |
| | | @Resource |
| | | private SysUserRoleClient sysUserRoleClient; |
| | | |
| | | @Resource |
| | | private IotInterfaceClient iotInterfaceClient; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | if(count > 0){ |
| | | return AjaxResult.error("设备编号已存在"); |
| | | } |
| | | this.save(chargingPile); |
| | | //调用华为Iot创建设备 |
| | | AddDevice addDevice = new AddDevice(); |
| | | addDevice.setProductId("66da68d21837002b28b34ec0"); |
| | | addDevice.setNodeId(chargingPile.getCode()); |
| | | addDevice.setDeviceName(chargingPile.getName()); |
| | | addDevice.setDescription(chargingPile.getNumber().toString()); |
| | | AddDeviceResp deviceResp = iotInterfaceClient.addDevice(addDevice).getData(); |
| | | if(null != deviceResp){ |
| | | int httpStatusCode = deviceResp.getHttpStatusCode(); |
| | | if(httpStatusCode == 201){ |
| | | chargingPile.setIotdDeviceId(deviceResp.getDeviceId()); |
| | | this.save(chargingPile); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public AjaxResult delChargingPile(Integer[] ids) { |
| | | //检查是否有关联数据 |
| | | //接口 |
| | | long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, Arrays.asList(ids)) |
| | | .eq(TChargingGun::getDelFlag, 0)); |
| | | if(count > 0){ |
| | |
| | | } |
| | | for (Integer id : ids) { |
| | | TChargingPile chargingPile = this.getById(id); |
| | | this.removeById(chargingPile); |
| | | //调用华为Iot删除设备 |
| | | if(StringUtils.isNotEmpty(chargingPile.getIotdDeviceId())){ |
| | | DeleteDeviceResp deviceResp = iotInterfaceClient.deleteDevice(chargingPile.getIotdDeviceId()).getData(); |
| | | if(null != deviceResp && deviceResp.getHttpStatusCode() == 201){ |
| | | this.removeById(chargingPile); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | List<TChargingGun> chargingGuns = chargingGunService.list(wrapper); |
| | | // 查询充电枪信息 |
| | | chargingPileVOS.forEach(item -> { |
| | | item.setChargingGunList(chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(item.getId())).collect(Collectors.toList())); |
| | | List<TChargingGun> chargingGunList = chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(item.getId())).collect(Collectors.toList()); |
| | | for (TChargingGun chargingGun : chargingGunList) { |
| | | if(chargingGun.getStatus().equals(4)){ |
| | | // TODO 查询正在充电的单子的实时记录 |
| | | chargingGun.setSoc(100); |
| | | } |
| | | if(chargingGun.getStatus().equals(5)){ |
| | | chargingGun.setSoc(100); |
| | | } |
| | | } |
| | | item.setChargingGunList(chargingGunList); |
| | | }); |
| | | return chargingPileVOS; |
| | | } |