桩号白名单接口完善done.
This commit is contained in:
parent
16792b4b98
commit
e07d3d6789
@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -59,7 +60,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService{
|
||||
XhpcTerminal xhpcTerminal =new XhpcTerminal();
|
||||
xhpcTerminal.setChargingStationId(chargingStationId);
|
||||
xhpcTerminal.setChargingPileId(chargingPileId);
|
||||
xhpcTerminal.setName(serialNumber+"-"+(i+1));
|
||||
xhpcTerminal.setName(serialNumber + "-" + (i + 1));
|
||||
xhpcTerminal.setPileSerialNumber(serialNumber);
|
||||
xhpcTerminal.setWorkStatus(2);
|
||||
xhpcTerminal.setStatus(0);
|
||||
@ -68,10 +69,9 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService{
|
||||
}
|
||||
|
||||
//插入redis 桩的编号
|
||||
ChargingPileDto charging = new ChargingPileDto();
|
||||
charging.setStationId(chargingStationId);
|
||||
charging.setPileNo(serialNumber);
|
||||
powerPileService.addPileWhitelist(charging);
|
||||
HashSet<String> noSet = new HashSet<>();
|
||||
noSet.add(serialNumber);
|
||||
powerPileService.addPileWhitelist(chargingStationId, noSet);
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@ -13,19 +13,21 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@FeignClient(contextId = "powerPileService", value = ServiceNameConstants.PILE_SERVICE, fallbackFactory = PowerPileFallbackFactory.class)
|
||||
public interface PowerPileService {
|
||||
|
||||
@PostMapping(value = "/charging/start")
|
||||
@PostMapping("/charging/start")
|
||||
R startCharging(@Validated @RequestBody StartChargingData startChargingData);
|
||||
|
||||
@PostMapping(value = "/pile/whitelist")
|
||||
R addPileWhitelist(@RequestBody ChargingPileDto chargingPileDto);
|
||||
@PostMapping("pile/whitelist/add/{stationId}")
|
||||
R addPileWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet);
|
||||
|
||||
@DeleteMapping(value = "/pile/whitelist/{stationId}/{pileNo}")
|
||||
R deletePileWhitelist(@PathVariable("stationId") Long stationId, @PathVariable("pileNo") String pileNo);
|
||||
@DeleteMapping("pile/whitelist/delete/{stationId}")
|
||||
R deletePileWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet);
|
||||
|
||||
@PostMapping(value = "/station/rateModel/{stationId}/{rateModelId}")
|
||||
R setStationRateModelId(@PathVariable("stationId") Long stationId, @PathVariable("rateModelId") Long rateModelId, @RequestBody CacheRateModel rateModel);
|
||||
@PostMapping("/station/rateModel/{stationId}/{rateModelId}")
|
||||
R setStationRateModel(@PathVariable("stationId") Long stationId, @PathVariable("rateModelId") Long rateModelId, @RequestBody CacheRateModel rateModel);
|
||||
|
||||
}
|
||||
|
||||
@ -9,7 +9,6 @@ public class ChargingStationDto {
|
||||
private Long stationId;
|
||||
private Set<String> piles;
|
||||
private Long rateModelId;
|
||||
private CacheRateModel rateModel;
|
||||
|
||||
public Long getStationId() {
|
||||
|
||||
@ -41,14 +40,4 @@ public class ChargingStationDto {
|
||||
this.rateModelId = rateModelId;
|
||||
}
|
||||
|
||||
public CacheRateModel getRateModel() {
|
||||
|
||||
return rateModel;
|
||||
}
|
||||
|
||||
public void setRateModel(CacheRateModel rateModel) {
|
||||
|
||||
this.rateModel = rateModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class PowerPileFallbackFactory implements FallbackFactory<PowerPileService> {
|
||||
|
||||
@ -28,19 +30,19 @@ public class PowerPileFallbackFactory implements FallbackFactory<PowerPileServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public R addPileWhitelist(ChargingPileDto chargingPileDto) {
|
||||
public R addPileWhitelist(Long stationId, Set<String> pileNoSet) {
|
||||
|
||||
return R.fail("增加充电桩白名单失败:" + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R deletePileWhitelist(Long stationId, String pileNo) {
|
||||
public R deletePileWhitelist(Long stationId, Set<String> pileNoSet) {
|
||||
|
||||
return R.fail("删除充电桩白名单失败:" + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R setStationRateModelId(Long stationId, Long rateModelId, CacheRateModel rateModel) {
|
||||
public R setStationRateModel(Long stationId, Long rateModelId, CacheRateModel rateModel) {
|
||||
|
||||
return R.fail("设置电站费率模型失败:" + cause.getMessage());
|
||||
}
|
||||
|
||||
@ -111,8 +111,9 @@ public class ChargingController {
|
||||
// not defined or implemented yet
|
||||
}
|
||||
String msg = HexUtils.toHex(data).concat(ServiceResult.HEX_OK);
|
||||
log.info("msg2bsent2pile:{}", msg);
|
||||
return HexUtils.toBytes(msg.concat(CRCCalculator.calcCrc(msg)));
|
||||
msg = msg.concat(CRCCalculator.calcCrc(msg));
|
||||
log.info("charging order[{}], send msg to pile: {}", startChargingData.getOrderNo(), msg);
|
||||
return HexUtils.toBytes(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.xhpc.common.core.domain.R;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -14,18 +15,12 @@ import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||
@RestController
|
||||
public class PileController {
|
||||
|
||||
@PostMapping("pile/whitelist")
|
||||
public Object addWhitelist(@RequestBody ChargingPileDto chargingPileDto) {
|
||||
@PostMapping("pile/whitelist/add/{stationId}")
|
||||
public Object addWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet) {
|
||||
|
||||
Set<String> pileWhitelist = REDIS.getCacheSet("PILE_WHITELIST");
|
||||
String pileNo = chargingPileDto.getPileNo();
|
||||
pileWhitelist.add(pileNo);
|
||||
pileWhitelist.addAll(pileNoSet);
|
||||
REDIS.setCacheSet("PILE_WHITELIST", pileWhitelist);
|
||||
String pileKey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pileKey);
|
||||
Long stationId = chargingPileDto.getStationId();
|
||||
cachePile.put("stationId", stationId);
|
||||
REDIS.setCacheMap(pileKey, cachePile);
|
||||
String stationKey = "station:".concat(stationId.toString());
|
||||
ChargingStationDto cacheStation = REDIS.getCacheObject(stationKey);
|
||||
if (cacheStation == null) {
|
||||
@ -34,19 +29,25 @@ public class PileController {
|
||||
}
|
||||
Set<String> stationPiles = cacheStation.getPiles();
|
||||
if (stationPiles == null) {
|
||||
stationPiles = new HashSet<>();
|
||||
cacheStation.setPiles(stationPiles);
|
||||
cacheStation.setPiles(pileNoSet);
|
||||
} else {
|
||||
stationPiles.addAll(pileNoSet);
|
||||
}
|
||||
stationPiles.add(pileNo);
|
||||
REDIS.setCacheObject(stationKey, cacheStation);
|
||||
for (String pileNo : pileNoSet) {
|
||||
String pileKey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pileKey);
|
||||
cachePile.put("stationId", stationId);
|
||||
REDIS.setCacheMap(pileKey, cachePile);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("pile/whitelist/{pileNo}")
|
||||
public Object deleteWhitelist(@PathVariable String pileNo) {
|
||||
@PostMapping("pile/whitelist/delete/{stationId}")
|
||||
public Object deleteWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet) {
|
||||
|
||||
Set<String> cacheWhitelist = REDIS.getCacheSet("PILE_WHITELIST");
|
||||
cacheWhitelist.remove(pileNo);
|
||||
cacheWhitelist.removeAll(pileNoSet);
|
||||
REDIS.setCacheSet("PILE_WHITELIST", cacheWhitelist);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ -8,7 +8,10 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||
|
||||
@ -21,8 +24,13 @@ public class StationController {
|
||||
String skey = "station:".concat(stationId.toString());
|
||||
ChargingStationDto cacheStation = REDIS.getCacheObject(skey);
|
||||
cacheStation.setRateModelId(rateModelId);
|
||||
cacheStation.setRateModel(rateModel);
|
||||
REDIS.setCacheObject(skey, cacheStation);
|
||||
String rkey = "rateModel:".concat(rateModelId.toString());
|
||||
REDIS.setCacheObject(rkey, rateModel);
|
||||
String srmkey = "settingRateModel:".concat(stationId.toString());
|
||||
Map<String, Object> rateModelPilesMap = new HashMap<>();
|
||||
rateModelPilesMap.put(rateModelId.toString(), cacheStation.getPiles());
|
||||
REDIS.setCacheMap(srmkey, rateModelPilesMap);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user