puzhibing
2025-02-11 0275498af38bc1c8fbc5bfea54f3cce3550fd6ab
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java
@@ -182,22 +182,28 @@
         return AjaxResult.error("设备编号已存在");
      }
      //调用华为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());
      ShowDeviceResp showDeviceResp = iotInterfaceClient.showDeviceRequest(chargingPile.getCode()).getData();
      if(null == showDeviceResp){
         //调用华为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());
            }else{
               log.error("华为创建设备失败" + JSON.toJSONString(deviceResp));
               return AjaxResult.error("华为创建设备失败");
            }
         }else{
            log.error("华为创建设备失败" + JSON.toJSONString(deviceResp));
            return AjaxResult.error("华为创建设备失败");
         }
      }else{
         return AjaxResult.error("华为创建设备失败");
         chargingPile.setIotdDeviceId(showDeviceResp.getDeviceId());
      }
      this.save(chargingPile);
      return AjaxResult.success();
@@ -302,6 +308,7 @@
         TChargingGun chargingGun1 = new TChargingGun();
         chargingGun1.setId(chargingGun.getId());
         chargingGun1.setFullNumber(chargingPile.getCode() + chargingGun.getCode());
         chargingGun1.setSiteId(chargingPile.getSiteId());
         chargingGunService.updateById(chargingGun1);
         
         //下发硬件充电二维码
@@ -479,12 +486,12 @@
      chargeTrend.put("value", value1);
      chargeMonitoring.setChargeTrend(chargeTrend);
      
      //每日利用率=当日充电度数/(总桩数量*桩总功率*24小时)
      //每日利用率=当日充电度数/(桩总功率*24小时)
      List<TChargingPile> list = this.list(new LambdaQueryWrapper<TChargingPile>().in(TChargingPile::getSiteId, siteIds).eq(TChargingPile::getDelFlag, 0));
      BigDecimal v = list.stream().map(TChargingPile::getRatedPower).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(4, RoundingMode.HALF_EVEN);
      List<Double> data = chargingOrderAccountingStrategyClient.getDailyChargingDegree(6, siteIds).getData();
      List<Double> value2 = new ArrayList<>();
      BigDecimal multiply = new BigDecimal(list.size()).multiply(v).multiply(new BigDecimal(24));
      BigDecimal multiply = v.multiply(new BigDecimal(24));
      for (Double datum : data) {
         if(list.size() == 0){
            value2.add(0D);