完成query_station_info接口,(增加了回调接口,保存场站状态与编辑场站状态)
This commit is contained in:
parent
68387d099f
commit
73ad931c6f
@ -0,0 +1,20 @@
|
|||||||
|
package com.xhpc.evcs.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wen
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class XhpcChargingStationPushStatus {
|
||||||
|
|
||||||
|
@JsonProperty("ChargingStationId")
|
||||||
|
private String chargingStationId;
|
||||||
|
|
||||||
|
@JsonProperty("PushStatus")
|
||||||
|
private String pushStatus;
|
||||||
|
|
||||||
|
}
|
||||||
@ -22,7 +22,7 @@ public class GlobalExceptionController extends ResponseEntityExceptionHandler {
|
|||||||
CommonResponse handleAllException(Throwable e) {
|
CommonResponse handleAllException(Throwable e) {
|
||||||
|
|
||||||
CommonResponse commonResponse = new CommonResponse();
|
CommonResponse commonResponse = new CommonResponse();
|
||||||
commonResponse.setRet(EvcsConst.RET_FAIl);
|
commonResponse.setRet(EvcsConst.RET_FAIL);
|
||||||
commonResponse.setMsg(e.getMessage());
|
commonResponse.setMsg(e.getMessage());
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
return commonResponse;
|
return commonResponse;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.xhpc.evcs.api;
|
package com.xhpc.evcs.api;
|
||||||
|
|
||||||
|
import com.xhpc.common.api.ChargingStationPushStatusService;
|
||||||
import com.xhpc.common.api.dto.ChargingStationDto;
|
import com.xhpc.common.api.dto.ChargingStationDto;
|
||||||
import com.xhpc.common.data.redis.CacheRateModel;
|
import com.xhpc.common.data.redis.CacheRateModel;
|
||||||
import com.xhpc.evcs.domain.XhpcChargingPile;
|
import com.xhpc.evcs.domain.XhpcChargingPile;
|
||||||
@ -28,6 +29,8 @@ import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
|||||||
@RestController
|
@RestController
|
||||||
public class QueryStationsInfoController {
|
public class QueryStationsInfoController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChargingStationPushStatusService chargingStationPushStatusService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private XhpcChargingPileRepository xhpcChargingPileRepository;
|
private XhpcChargingPileRepository xhpcChargingPileRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -38,12 +41,15 @@ public class QueryStationsInfoController {
|
|||||||
|
|
||||||
@PostMapping("/v1/query_stations_info")
|
@PostMapping("/v1/query_stations_info")
|
||||||
public CommonResponse queryStationsInfo(@RequestBody(required = false) CommonRequest<PageRequest> commonRequest) throws Exception {
|
public CommonResponse queryStationsInfo(@RequestBody(required = false) CommonRequest<PageRequest> commonRequest) throws Exception {
|
||||||
|
// todo 电站状态更新逻辑
|
||||||
|
// chargingStationPushStatusService.editStationStatus();
|
||||||
|
// chargingStationPushStatusService.saveStationStatus();
|
||||||
|
|
||||||
//当前页数
|
//当前页数
|
||||||
PageRequest pageRequest1 = commonRequest.transformDataType(PageRequest.class);
|
PageRequest pageRequest = commonRequest.transformDataType(PageRequest.class);
|
||||||
Integer pageNo1 = pageRequest1.getPageNo();
|
Integer pageNo = pageRequest.getPageNo();
|
||||||
PageStationsInfoResponse response = new PageStationsInfoResponse();
|
PageStationsInfoResponse response = new PageStationsInfoResponse();
|
||||||
response.setPageNo(pageNo1);
|
response.setPageNo(pageNo);
|
||||||
//页码总数
|
//页码总数
|
||||||
String operatorId = commonRequest.getOperatorId();
|
String operatorId = commonRequest.getOperatorId();
|
||||||
List<XhpcStationInternetBlacklist> xhpcStationInternetBlacklist = xhpcStationInternetBlacklistRepo.findByInternetUserId(operatorId);
|
List<XhpcStationInternetBlacklist> xhpcStationInternetBlacklist = xhpcStationInternetBlacklistRepo.findByInternetUserId(operatorId);
|
||||||
@ -64,8 +70,8 @@ public class QueryStationsInfoController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (validStationKeys.size() > 0) {
|
if (validStationKeys.size() > 0) {
|
||||||
Integer pageSize1 = pageRequest1.getPageSize();
|
Integer pageSize = pageRequest.getPageSize();
|
||||||
int totalPage = validStationKeys.size() % pageSize1 == 0 ? validStationKeys.size() % pageSize1 : (validStationKeys.size() % pageSize1) + 1;
|
int totalPage = validStationKeys.size() % pageSize == 0 ? validStationKeys.size() / pageSize : (validStationKeys.size() / pageSize) + 1;
|
||||||
response.setPageCount(totalPage);
|
response.setPageCount(totalPage);
|
||||||
}
|
}
|
||||||
//总记录条数
|
//总记录条数
|
||||||
@ -74,11 +80,23 @@ public class QueryStationsInfoController {
|
|||||||
//充电站信息列表
|
//充电站信息列表
|
||||||
List<StationInfo> stationInfos = new ArrayList<>();
|
List<StationInfo> stationInfos = new ArrayList<>();
|
||||||
//计算每页开始索引
|
//计算每页开始索引
|
||||||
Integer pageSize1 = pageRequest1.getPageSize();
|
int startIndex = -1;
|
||||||
int startIndex = (pageNo1 - 1) * pageSize1;
|
int endIndex = -1;
|
||||||
int endIndex = startIndex + (pageSize1 - 1);
|
if (pageNo == 1 && validStationKeys.size() <= 10) {
|
||||||
|
startIndex = 0;
|
||||||
|
endIndex = validStationKeys.size() - 1;
|
||||||
|
} else {
|
||||||
|
Integer pageSize = pageRequest.getPageSize();
|
||||||
|
startIndex = (pageNo - 1) * pageSize;
|
||||||
|
endIndex = startIndex + (pageSize - 1);
|
||||||
|
}
|
||||||
for (int i = startIndex; i <= endIndex; i++) {
|
for (int i = startIndex; i <= endIndex; i++) {
|
||||||
String stationKey = validStationKeys.get(i);
|
String stationKey = null;
|
||||||
|
try {
|
||||||
|
stationKey = validStationKeys.get(i);
|
||||||
|
} catch (Exception e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationKey);
|
ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationKey);
|
||||||
StationInfo stationInfo = new StationInfo();
|
StationInfo stationInfo = new StationInfo();
|
||||||
stationInfo.setStationId(String.valueOf(chargingStationDto.getStationId()));
|
stationInfo.setStationId(String.valueOf(chargingStationDto.getStationId()));
|
||||||
@ -210,7 +228,9 @@ public class QueryStationsInfoController {
|
|||||||
private String[] getFees(Long rateModelId) {
|
private String[] getFees(Long rateModelId) {
|
||||||
|
|
||||||
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(rateModelId.toString()));
|
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(rateModelId.toString()));
|
||||||
if (cacheRateModel.getPp() != null) return cacheRateModel.getPp();
|
if (cacheRateModel.getPp() != null) {
|
||||||
|
return cacheRateModel.getPp();
|
||||||
|
}
|
||||||
String[] tfPricesSeq = cacheRateModel.getTfPricesSeq();
|
String[] tfPricesSeq = cacheRateModel.getTfPricesSeq();
|
||||||
String startTf = "00:00";
|
String startTf = "00:00";
|
||||||
String endTf = "";
|
String endTf = "";
|
||||||
@ -309,7 +329,7 @@ public class QueryStationsInfoController {
|
|||||||
String gunId = pileNo.concat(String.format("%02d", i));
|
String gunId = pileNo.concat(String.format("%02d", i));
|
||||||
ConnectorInfo connectorInfo = new ConnectorInfo();
|
ConnectorInfo connectorInfo = new ConnectorInfo();
|
||||||
connectorInfo.setConnectorID(gunId);
|
connectorInfo.setConnectorID(gunId);
|
||||||
String connectorName = REDIS.getCacheMapValue("gun:".concat(gunId), "terminalName"); //todo setem in redis!
|
String connectorName = REDIS.getCacheMapValue("gun:".concat(gunId), "terminalName"); //todo set them in redis!
|
||||||
connectorInfo.setConnectorName(connectorName == null ?
|
connectorInfo.setConnectorName(connectorName == null ?
|
||||||
Integer.parseInt(pileNo.substring(5, 10)) + "号桩 " + GUNNAMES[i] +
|
Integer.parseInt(pileNo.substring(5, 10)) + "号桩 " + GUNNAMES[i] +
|
||||||
"枪" : connectorName);
|
"枪" : connectorName);
|
||||||
|
|||||||
@ -5,9 +5,12 @@ package com.xhpc.common.core.constant;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class ServiceNameConstants
|
public class ServiceNameConstants {
|
||||||
{
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EVCS服务
|
||||||
|
*/
|
||||||
|
public static final String XHPC_EVCS = "evcs";
|
||||||
/**
|
/**
|
||||||
* 认证服务service id
|
* 认证服务service id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
package com.xhpc.charging.station.controller;
|
package com.xhpc.charging.station.controller;
|
||||||
|
|
||||||
|
import com.xhpc.charging.station.service.IXhpcChargingStationService;
|
||||||
|
import com.xhpc.common.api.dto.XhpcChargingStationDto;
|
||||||
import com.xhpc.common.core.web.controller.BaseController;
|
import com.xhpc.common.core.web.controller.BaseController;
|
||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
import com.xhpc.common.core.web.page.TableDataInfo;
|
import com.xhpc.common.core.web.page.TableDataInfo;
|
||||||
|
import com.xhpc.common.domain.XhpcChargingStation;
|
||||||
import com.xhpc.common.log.annotation.Log;
|
import com.xhpc.common.log.annotation.Log;
|
||||||
import com.xhpc.common.log.enums.BusinessType;
|
import com.xhpc.common.log.enums.BusinessType;
|
||||||
import com.xhpc.common.security.annotation.PreAuthorize;
|
import com.xhpc.common.security.annotation.PreAuthorize;
|
||||||
import com.xhpc.common.domain.XhpcChargingStation;
|
|
||||||
import com.xhpc.common.api.dto.XhpcChargingStationDto;
|
|
||||||
import com.xhpc.charging.station.service.IXhpcChargingStationService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -30,6 +30,37 @@ public class XhpcChargingStationController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IXhpcChargingStationService xhpcChargingStationService;
|
private IXhpcChargingStationService xhpcChargingStationService;
|
||||||
|
|
||||||
|
@PostMapping("/editStationStatus")
|
||||||
|
public AjaxResult editStationStatus(@RequestBody Map<String, Object> map) {
|
||||||
|
|
||||||
|
//空值判断
|
||||||
|
if (map.get("chargingStationId") == null && map.get("pushStatus") == null) {
|
||||||
|
return AjaxResult.error("chargingStationId or pushStatus or stationName is null");
|
||||||
|
}
|
||||||
|
Integer integer = xhpcChargingStationService.editStationsStatus((List<Integer>) map.get("chargingStationId"), (Integer) map.get("pushStatus"));
|
||||||
|
return AjaxResult.success("充电站状态编辑成功", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/saveStationStatus")
|
||||||
|
public AjaxResult saveStationStatus(@RequestBody Map<String, Object> map) {
|
||||||
|
|
||||||
|
//空值判断
|
||||||
|
if (map.get("chargingStationId") == null && map.get("pushStatus") == null && map.get("stationName") == null) {
|
||||||
|
|
||||||
|
return AjaxResult.error("chargingStationId or pushStatus or stationName is null");
|
||||||
|
}
|
||||||
|
Boolean result = xhpcChargingStationService.findOneByStationId((Integer) map.get("chargingStationId"));
|
||||||
|
//电站表中是否有对应的电站存在
|
||||||
|
if (!result) {
|
||||||
|
return AjaxResult.error("chargingStationId is not exist");
|
||||||
|
}
|
||||||
|
Integer integer = xhpcChargingStationService.saveStationStatus((Integer) map.get("chargingStationId"), (String) map.get("stationName"), (Integer) map.get("pushStatus"));
|
||||||
|
//是否重复判断,保证唯一
|
||||||
|
if (integer == 0) {
|
||||||
|
return AjaxResult.error("chargingStationId doesn't repeat");
|
||||||
|
}
|
||||||
|
return AjaxResult.success("充电站状态保存成功", null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询电站列表
|
* 查询电站列表
|
||||||
|
|||||||
@ -0,0 +1,48 @@
|
|||||||
|
package com.xhpc.charging.station.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapper Class of the table of the xhpc_charging_station_push_status
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2021/11/4 11:16
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
public interface XhpcChargingStationPushStatusMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存充电站推送状态
|
||||||
|
*
|
||||||
|
* @param chargingStationId id of charging station
|
||||||
|
* @param pushStatus push status
|
||||||
|
* @param stationName
|
||||||
|
* @return Integer success or fail
|
||||||
|
* @author WH
|
||||||
|
* @date 2021/11/4 12:54
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
Integer saveStationPushStatus(@Param("chargingStationId") Integer chargingStationId, @Param("stationName") String stationName, @Param("pushStatus") Integer pushStatus);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找电站id是否已经存在
|
||||||
|
*
|
||||||
|
* @param chargingStationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map<String, Object> findOne(Integer chargingStationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑一个或多个场站状态
|
||||||
|
*
|
||||||
|
* @param chargingStationIds
|
||||||
|
* @param pushStatus
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer editStationsStatus(@Param("chargingStationIds") List<Integer> chargingStationIds, @Param("pushStatus") Integer pushStatus);
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
package com.xhpc.charging.station.service;
|
package com.xhpc.charging.station.service;
|
||||||
|
|
||||||
|
import com.xhpc.common.api.dto.XhpcChargingStationDto;
|
||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
import com.xhpc.common.domain.XhpcChargingStation;
|
import com.xhpc.common.domain.XhpcChargingStation;
|
||||||
import com.xhpc.common.api.dto.XhpcChargingStationDto;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -15,6 +15,16 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface IXhpcChargingStationService {
|
public interface IXhpcChargingStationService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存电站状态
|
||||||
|
*
|
||||||
|
* @param chargingStationId 要保存的电站的id
|
||||||
|
* @param stationName 充电站名称
|
||||||
|
* @param pushStatus 电站的状态 0,1(1表示修改了)
|
||||||
|
* @return success or fail
|
||||||
|
*/
|
||||||
|
Integer saveStationStatus(Integer chargingStationId, String stationName, Integer pushStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询电站
|
* 查询电站
|
||||||
*
|
*
|
||||||
@ -177,14 +187,32 @@ public interface IXhpcChargingStationService {
|
|||||||
* @param chargingStationId
|
* @param chargingStationId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Object> getTerminalStatusSum(Map<String, Object> map, Long chargingStationId,Integer status);
|
Map<String, Object> getTerminalStatusSum(Map<String, Object> map, Long chargingStationId, Integer status);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单个终端状态(所有状态集合)
|
* 单个终端状态(所有状态集合)
|
||||||
|
*
|
||||||
* @param serialNumber
|
* @param serialNumber
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer getTerminalStatus(String serialNumber);
|
Integer getTerminalStatus(String serialNumber);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查找对应的场站
|
||||||
|
*
|
||||||
|
* @param chargingStationId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Boolean findOneByStationId(Integer chargingStationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑一个或多个充电站状态
|
||||||
|
*
|
||||||
|
* @param chargingStationId
|
||||||
|
* @param pushStatus
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer editStationsStatus(List<Integer> chargingStationId, Integer pushStatus);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.xhpc.charging.station.service;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.xhpc.charging.station.mapper.XhpcChargingStationMapper;
|
import com.xhpc.charging.station.mapper.XhpcChargingStationMapper;
|
||||||
|
import com.xhpc.charging.station.mapper.XhpcChargingStationPushStatusMapper;
|
||||||
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;
|
||||||
import com.xhpc.common.api.dto.XhpcRateDto;
|
import com.xhpc.common.api.dto.XhpcRateDto;
|
||||||
@ -48,8 +49,34 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
|||||||
private PowerPileService powerPileService;
|
private PowerPileService powerPileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
@Autowired
|
||||||
|
private XhpcChargingStationPushStatusMapper xhpcChargingStationPushStatusMapper;
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(XhpcChargingStationServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(XhpcChargingStationServiceImpl.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer editStationsStatus(List<Integer> chargingStationIds, Integer pushStatus) {
|
||||||
|
|
||||||
|
return xhpcChargingStationPushStatusMapper.editStationsStatus(chargingStationIds, pushStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存电站状态
|
||||||
|
*
|
||||||
|
* @param chargingStationId 要保存的电站的id
|
||||||
|
* @param pushStatus 电站的状态 0,1(1表示修改了)
|
||||||
|
* @return greater than 0 means success
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Integer saveStationStatus(Integer chargingStationId, String stationName, Integer pushStatus) {
|
||||||
|
|
||||||
|
Map<String, Object> map = xhpcChargingStationPushStatusMapper.findOne(chargingStationId);
|
||||||
|
if (map != null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return xhpcChargingStationPushStatusMapper.saveStationPushStatus(chargingStationId, stationName, pushStatus);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询电站
|
* 查询电站
|
||||||
*
|
*
|
||||||
@ -1073,6 +1100,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getTerminalStatus(String serialNumber) {
|
public Integer getTerminalStatus(String serialNumber) {
|
||||||
|
|
||||||
Integer status =0;
|
Integer status =0;
|
||||||
//终端状态用 redis数据
|
//终端状态用 redis数据
|
||||||
if(!"".equals(serialNumber) && serialNumber!=null){
|
if(!"".equals(serialNumber) && serialNumber!=null){
|
||||||
@ -1090,17 +1118,24 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//充电桩
|
//充电桩
|
||||||
status =3;
|
status = 3;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
status =5;
|
status = 5;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
status =5;
|
status = 5;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean findOneByStationId(Integer chargingStationId) {
|
||||||
|
|
||||||
|
XhpcChargingStation xhpcChargingStation = xhpcChargingStationMapper.selectXhpcChargingStationById(Long.valueOf(chargingStationId));
|
||||||
|
return xhpcChargingStation != null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
//时间差
|
//时间差
|
||||||
// String startTime="01:00:00";
|
// String startTime="01:00:00";
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.xhpc.charging.station.mapper.XhpcChargingStationPushStatusMapper">
|
||||||
|
|
||||||
|
<update id="editStationsStatus">
|
||||||
|
update xhpc_charging_station_push_status set push_status = #{pushStatus}
|
||||||
|
<where>
|
||||||
|
charging_station_id
|
||||||
|
<foreach collection="chargingStationIds" separator="," open="in (" close=")" item="id">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</where>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<insert id="saveStationPushStatus">
|
||||||
|
insert into xhpc_charging_station_push_status (charging_station_id, station_name, push_status)
|
||||||
|
values (#{chargingStationId}, #{stationName}, #{pushStatus})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="findOne" resultType="Map" parameterType="integer">
|
||||||
|
select *
|
||||||
|
from xhpc_charging_station_push_status
|
||||||
|
where charging_station_id = #{chargingStationId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.xhpc.common.api;
|
||||||
|
|
||||||
|
import com.xhpc.common.api.factory.ChargingStationPushStatusFallbackFactory;
|
||||||
|
import com.xhpc.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于evcs的跨服务调用
|
||||||
|
* save station status and edit station
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2021/11/5 10:05
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "ChargingStationPushStatusService", value = ServiceNameConstants.XHPC_EVCS, fallbackFactory = ChargingStationPushStatusFallbackFactory.class)
|
||||||
|
public interface ChargingStationPushStatusService {
|
||||||
|
|
||||||
|
@PostMapping("/station/editStationStatus")
|
||||||
|
AjaxResult editStationStatus(@RequestBody Map<String, Object> map);
|
||||||
|
|
||||||
|
@PostMapping("/station/saveStationStatus")
|
||||||
|
AjaxResult saveStationStatus(@RequestBody Map<String, Object> map);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
package com.xhpc.common.api.factory;
|
||||||
|
|
||||||
|
import com.xhpc.common.api.ChargingStationPushStatusService;
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author WH
|
||||||
|
* @date 2021/11/5 10:10
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class ChargingStationPushStatusFallbackFactory implements FallbackFactory<ChargingStationPushStatusService> {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ChargingStationPushStatusFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChargingStationPushStatusService create(Throwable cause) {
|
||||||
|
|
||||||
|
logger.error("场站状态服务调用失败:{}//fallback", cause.getMessage());
|
||||||
|
|
||||||
|
return new ChargingStationPushStatusService() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult editStationStatus(Map<String, Object> map) {
|
||||||
|
|
||||||
|
return AjaxResult.error("场站编辑回调接口失败:" + cause.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult saveStationStatus(Map<String, Object> map) {
|
||||||
|
|
||||||
|
return AjaxResult.error("场站保存回调接口失败:" + cause.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user