diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java index b05b17c1..9593ea0c 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java @@ -89,10 +89,17 @@ public interface XhpcChargingPileMapper { int updateXhpcTerminal(@Param("chargingPileId") Long chargingPileId); /** - * 统计改场站的终端 + * 统计场站的桩的数量 * @param chargingStationId * @return */ int countXhpcTerminal(@Param("chargingStationId") Long chargingStationId); + /** + * 对应场站的终端数量 + * @param chargingStationId + * @return + */ + int pileCount(@Param("chargingStationId") Long chargingStationId); + } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java index 9150a16f..c457dec9 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java @@ -198,7 +198,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService { if (i > 0) { //删除桩 Set set = new HashSet<>(); - set.add(chargingPileId + ""); + set.add(xhpc.getSerialNumber()); powerPileService.deletePileWhitelist(xhpc.getChargingStationId(), set); return 1; } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java index 4e3a52ba..19a1b7b8 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java @@ -3,6 +3,7 @@ package com.xhpc.charging.station.service; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; +import com.xhpc.charging.station.mapper.XhpcChargingPileMapper; import com.xhpc.charging.station.mapper.XhpcChargingStationMapper; import com.xhpc.common.api.PowerPileService; import com.xhpc.common.api.dto.XhpcChargingStationDto; @@ -12,10 +13,7 @@ import com.xhpc.common.core.domain.R; import com.xhpc.common.core.utils.DateUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.redis.CacheRateModel; -import com.xhpc.common.domain.XhpcChargingStation; -import com.xhpc.common.domain.XhpcRate; -import com.xhpc.common.domain.XhpcRateModel; -import com.xhpc.common.domain.XhpcRateTime; +import com.xhpc.common.domain.*; import com.xhpc.common.redis.service.RedisService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +46,8 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi private PowerPileService powerPileService; @Autowired private RedisService redisService; + @Autowired + private XhpcChargingPileMapper xhpcChargingPileMapper; private static final Logger logger = LoggerFactory.getLogger(XhpcChargingStationServiceImpl.class); /** @@ -139,10 +139,18 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi @Override public int updateXhpcChargingStationById(Long chargingStationId) { + int count = xhpcChargingPileMapper.pileCount(chargingStationId); + if (count>0){ + throw new RuntimeException("该场站下面还有桩,不能删除"); + } + int i = xhpcChargingStationMapper.updateXhpcChargingStationById(chargingStationId); if (i > 0) { extracted(1, chargingStationId); + //删除redis中的缓存数据 + redisService.deleteObject("station:"+chargingStationId); } + return i; } diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml index 220cd49f..8a5dbb08 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml @@ -397,4 +397,8 @@ + + diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java index 91c6c304..07075add 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java @@ -50,11 +50,8 @@ public class PileController { @DeleteMapping("pile/whitelist/delete/{stationId}") public Object deleteWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set pileNoSet) { -// System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); -// System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); REDIS.deleteSetVal("PILE_WHITELIST", pileNoSet.toArray()); String stationKey = "station:".concat(stationId.toString()); -// System.out.println(">>>>>>>>>>>>>>>>>>pileNoSet.toArray()>>>>>>>>>>>>>>>>"+stationKey); ChargingStationDto cacheStation = REDIS.getCacheObject(stationKey); cacheStation.getPiles().removeAll(pileNoSet); REDIS.setCacheObject(stationKey, cacheStation);