修改删除场站逻辑
This commit is contained in:
parent
cfce6e7dba
commit
3ddc900bc9
@ -89,10 +89,17 @@ public interface XhpcChargingPileMapper {
|
|||||||
int updateXhpcTerminal(@Param("chargingPileId") Long chargingPileId);
|
int updateXhpcTerminal(@Param("chargingPileId") Long chargingPileId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计改场站的终端
|
* 统计场站的桩的数量
|
||||||
* @param chargingStationId
|
* @param chargingStationId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int countXhpcTerminal(@Param("chargingStationId") Long chargingStationId);
|
int countXhpcTerminal(@Param("chargingStationId") Long chargingStationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应场站的终端数量
|
||||||
|
* @param chargingStationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int pileCount(@Param("chargingStationId") Long chargingStationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -198,7 +198,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService {
|
|||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
//删除桩
|
//删除桩
|
||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
set.add(chargingPileId + "");
|
set.add(xhpc.getSerialNumber());
|
||||||
powerPileService.deletePileWhitelist(xhpc.getChargingStationId(), set);
|
powerPileService.deletePileWhitelist(xhpc.getChargingStationId(), set);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.xhpc.charging.station.service;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUnit;
|
import cn.hutool.core.date.DateUnit;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.xhpc.charging.station.mapper.XhpcChargingPileMapper;
|
||||||
import com.xhpc.charging.station.mapper.XhpcChargingStationMapper;
|
import com.xhpc.charging.station.mapper.XhpcChargingStationMapper;
|
||||||
import com.xhpc.common.api.PowerPileService;
|
import com.xhpc.common.api.PowerPileService;
|
||||||
import com.xhpc.common.api.dto.XhpcChargingStationDto;
|
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.utils.DateUtils;
|
||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
import com.xhpc.common.data.redis.CacheRateModel;
|
import com.xhpc.common.data.redis.CacheRateModel;
|
||||||
import com.xhpc.common.domain.XhpcChargingStation;
|
import com.xhpc.common.domain.*;
|
||||||
import com.xhpc.common.domain.XhpcRate;
|
|
||||||
import com.xhpc.common.domain.XhpcRateModel;
|
|
||||||
import com.xhpc.common.domain.XhpcRateTime;
|
|
||||||
import com.xhpc.common.redis.service.RedisService;
|
import com.xhpc.common.redis.service.RedisService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -48,6 +46,8 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
|||||||
private PowerPileService powerPileService;
|
private PowerPileService powerPileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
@Autowired
|
||||||
|
private XhpcChargingPileMapper xhpcChargingPileMapper;
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(XhpcChargingStationServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(XhpcChargingStationServiceImpl.class);
|
||||||
/**
|
/**
|
||||||
@ -139,10 +139,18 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
|||||||
@Override
|
@Override
|
||||||
public int updateXhpcChargingStationById(Long chargingStationId) {
|
public int updateXhpcChargingStationById(Long chargingStationId) {
|
||||||
|
|
||||||
|
int count = xhpcChargingPileMapper.pileCount(chargingStationId);
|
||||||
|
if (count>0){
|
||||||
|
throw new RuntimeException("该场站下面还有桩,不能删除");
|
||||||
|
}
|
||||||
|
|
||||||
int i = xhpcChargingStationMapper.updateXhpcChargingStationById(chargingStationId);
|
int i = xhpcChargingStationMapper.updateXhpcChargingStationById(chargingStationId);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
extracted(1, chargingStationId);
|
extracted(1, chargingStationId);
|
||||||
|
//删除redis中的缓存数据
|
||||||
|
redisService.deleteObject("station:"+chargingStationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -397,4 +397,8 @@
|
|||||||
<select id="countXhpcTerminal" resultType="int">
|
<select id="countXhpcTerminal" resultType="int">
|
||||||
select count(charging_pile_id) from xhpc_charging_pile where charging_station_id = #{chargingStationId}
|
select count(charging_pile_id) from xhpc_charging_pile where charging_station_id = #{chargingStationId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="PileCount" resultType="java.lang.Integer">
|
||||||
|
select count(charging_pile_id) from xhpc_charging_pile WHERE charging_station_id =#{chargingStationId} and def_flag=0
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -50,11 +50,8 @@ public class PileController {
|
|||||||
@DeleteMapping("pile/whitelist/delete/{stationId}")
|
@DeleteMapping("pile/whitelist/delete/{stationId}")
|
||||||
public Object deleteWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet) {
|
public Object deleteWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet) {
|
||||||
|
|
||||||
// System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
|
||||||
// System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
|
||||||
REDIS.deleteSetVal("PILE_WHITELIST", pileNoSet.toArray());
|
REDIS.deleteSetVal("PILE_WHITELIST", pileNoSet.toArray());
|
||||||
String stationKey = "station:".concat(stationId.toString());
|
String stationKey = "station:".concat(stationId.toString());
|
||||||
// System.out.println(">>>>>>>>>>>>>>>>>>pileNoSet.toArray()>>>>>>>>>>>>>>>>"+stationKey);
|
|
||||||
ChargingStationDto cacheStation = REDIS.getCacheObject(stationKey);
|
ChargingStationDto cacheStation = REDIS.getCacheObject(stationKey);
|
||||||
cacheStation.getPiles().removeAll(pileNoSet);
|
cacheStation.getPiles().removeAll(pileNoSet);
|
||||||
REDIS.setCacheObject(stationKey, cacheStation);
|
REDIS.setCacheObject(stationKey, cacheStation);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user