mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-13 14:30:08 +08:00
新增 运营端小程序查询枪口信息列表接口
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
package com.jsowell.api.uniapp.business;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.jsowell.common.core.controller.BaseController;
|
||||||
|
import com.jsowell.common.response.RestApiResponse;
|
||||||
|
import com.jsowell.pile.dto.business.QueryConnectorInfoDTO;
|
||||||
|
import com.jsowell.pile.service.PileConnectorInfoService;
|
||||||
|
import com.jsowell.pile.vo.uniapp.business.BusinessConnectorInfoVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运营端小程序枪口信息相关controller
|
||||||
|
*
|
||||||
|
* @author Lemon
|
||||||
|
* @Date 2024/8/27 16:04:31
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/business/pile/connector")
|
||||||
|
public class BusinessConnectorInfoController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PileConnectorInfoService pileConnectorInfoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取枪口信息列表
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/getBusinessConnectorInfoList")
|
||||||
|
public RestApiResponse<?> getBusinessConnectorInfoList(@RequestBody QueryConnectorInfoDTO dto) {
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
BusinessConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getConnectorListByStationAndStatus(dto);
|
||||||
|
response = new RestApiResponse<>(ImmutableMap.of("ConnectorInfoVO", connectorInfoVO));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("获取枪口信息列表 error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
|
}
|
||||||
|
logger.info("获取枪口信息列表 params:{}, result:{}", JSONObject.toJSONString(dto), response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import com.jsowell.pile.dto.QueryConnectorListDTO;
|
|||||||
import com.jsowell.pile.dto.UpdateConnectorParkNoDTO;
|
import com.jsowell.pile.dto.UpdateConnectorParkNoDTO;
|
||||||
import com.jsowell.pile.dto.business.QueryConnectorInfoDTO;
|
import com.jsowell.pile.dto.business.QueryConnectorInfoDTO;
|
||||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.business.BusinessConnectorInfoVO;
|
||||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -141,5 +142,5 @@ public interface PileConnectorInfoService {
|
|||||||
/**
|
/**
|
||||||
* 通过站点id和枪口状态查询枪口列表
|
* 通过站点id和枪口状态查询枪口列表
|
||||||
*/
|
*/
|
||||||
void getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto);
|
BusinessConnectorInfoVO getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.jsowell.pile.mapper.PileBasicInfoMapper;
|
|||||||
import com.jsowell.pile.mapper.PileConnectorInfoMapper;
|
import com.jsowell.pile.mapper.PileConnectorInfoMapper;
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.business.BusinessConnectorInfoVO;
|
||||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||||
@@ -772,29 +773,84 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量获取枪口状态
|
* 批量获取某状态的枪口数量
|
||||||
* @param pileConnectorCodeList
|
* @param pileConnectorCodeList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Map<String, String> getConnectorStatus(List<String> pileConnectorCodeList) {
|
private Map<String, Integer> getConnectorStatus(List<String> pileConnectorCodeList) {
|
||||||
List<PileConnectorInfo> pileConnectorInfos = pileConnectorInfoMapper.getConnectorStatus(pileConnectorCodeList);
|
List<PileConnectorInfo> pileConnectorInfos = pileConnectorInfoMapper.getConnectorStatus(pileConnectorCodeList);
|
||||||
|
int offlineNum = Constants.zero;
|
||||||
|
int freeNum = Constants.zero;
|
||||||
|
int occupiedNum = Constants.zero;
|
||||||
|
int chargingNum = Constants.zero;
|
||||||
|
int faultNum = Constants.zero;
|
||||||
for (PileConnectorInfo pileConnectorInfo : pileConnectorInfos) {
|
for (PileConnectorInfo pileConnectorInfo : pileConnectorInfos) {
|
||||||
String status = pileConnectorInfo.getStatus();
|
String status = pileConnectorInfo.getStatus();
|
||||||
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue())) {
|
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue())) {
|
||||||
|
// 离网
|
||||||
|
offlineNum += 1;
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.FREE.getValue())) {
|
||||||
|
// 空闲
|
||||||
|
freeNum += 1;
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue())) {
|
||||||
|
// 占用未充电
|
||||||
|
occupiedNum += 1;
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) {
|
||||||
|
// 充电中
|
||||||
|
chargingNum += 1;
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.FAULT.getValue())) {
|
||||||
|
// 故障
|
||||||
|
faultNum += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
Map<String, Integer> map = new LinkedHashMap<>();
|
||||||
|
map.put("offlineNum", offlineNum);
|
||||||
|
map.put("freeNum", freeNum);
|
||||||
|
map.put("occupiedNum", occupiedNum);
|
||||||
|
map.put("chargingNum", chargingNum);
|
||||||
|
map.put("faultNum", faultNum);
|
||||||
|
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 后管小程序 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 后管小程序 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询站点枪口列表
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto) {
|
public BusinessConnectorInfoVO getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto) {
|
||||||
String stationId = dto.getStationId();
|
String stationId = dto.getStationId();
|
||||||
String connectorStatus = dto.getConnectorStatus();
|
String connectorStatus = dto.getConnectorStatus();
|
||||||
int pageNum = dto.getPageNum();
|
int pageNum = dto.getPageNum();
|
||||||
int pageSize = dto.getPageSize();
|
int pageSize = dto.getPageSize();
|
||||||
|
BusinessConnectorInfoVO vo = new BusinessConnectorInfoVO();
|
||||||
|
// 根据站点id查询枪口列表(有缓存)
|
||||||
|
List<ConnectorInfoVO> uniAppConnectorList = getUniAppConnectorList(Long.parseLong(stationId));
|
||||||
|
// 筛选出枪口编号
|
||||||
|
List<String> pileConnectorCodeList = uniAppConnectorList.stream()
|
||||||
|
.map(ConnectorInfoVO::getPileConnectorCode)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 批量获取某状态的枪口数量
|
||||||
|
Map<String, Integer> connectorStatusNumMap = getConnectorStatus(pileConnectorCodeList);
|
||||||
|
Integer offlineNum = connectorStatusNumMap.get("offlineNum");
|
||||||
|
Integer freeNum = connectorStatusNumMap.get("freeNum");
|
||||||
|
Integer occupiedNum = connectorStatusNumMap.get("occupiedNum");
|
||||||
|
Integer chargingNum = connectorStatusNumMap.get("chargingNum");
|
||||||
|
Integer faultNum = connectorStatusNumMap.get("faultNum");
|
||||||
|
|
||||||
|
vo.setConnectorNum(pileConnectorCodeList.size());
|
||||||
|
vo.setOfflineConnectorNum(offlineNum);
|
||||||
|
vo.setFreeConnectorNum(freeNum);
|
||||||
|
vo.setOccupiedConnectorNum(occupiedNum);
|
||||||
|
vo.setChargingConnectorNum(chargingNum);
|
||||||
|
vo.setFaultConnectorNum(faultNum);
|
||||||
|
|
||||||
// 根据站点id和枪口状态查询枪口列表
|
// 根据站点id和枪口状态查询枪口列表
|
||||||
QueryConnectorListDTO queryConnectorListDTO = QueryConnectorListDTO.builder()
|
QueryConnectorListDTO queryConnectorListDTO = QueryConnectorListDTO.builder()
|
||||||
@@ -810,5 +866,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vo.setPileConnectorInfoVOList(pileConnectorInfoVOList);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,37 +32,37 @@ public class BusinessConnectorInfoVO {
|
|||||||
/**
|
/**
|
||||||
* 总枪口数量
|
* 总枪口数量
|
||||||
*/
|
*/
|
||||||
private String connectorNum;
|
private Integer connectorNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电中枪口数量
|
* 充电中枪口数量
|
||||||
*/
|
*/
|
||||||
private String chargingConnectorNum;
|
private Integer chargingConnectorNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空闲枪口数量
|
* 空闲枪口数量
|
||||||
*/
|
*/
|
||||||
private String freeConnectorNum;
|
private Integer freeConnectorNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 挂起枪口数量
|
* 挂起枪口数量
|
||||||
*/
|
*/
|
||||||
private String hangingConnectorNum;
|
private Integer hangingConnectorNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 占用中枪口数量
|
* 占用中枪口数量
|
||||||
*/
|
*/
|
||||||
private String occupiedConnectorNum;
|
private Integer occupiedConnectorNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 离线枪口数量
|
* 离线枪口数量
|
||||||
*/
|
*/
|
||||||
private String offlineConnectorNum;
|
private Integer offlineConnectorNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障枪口数量
|
* 故障枪口数量
|
||||||
*/
|
*/
|
||||||
private String faultConnectorNum;
|
private Integer faultConnectorNum;
|
||||||
|
|
||||||
private List<PileConnectorInfoVO> pileConnectorInfoVOList;
|
private List<PileConnectorInfoVO> pileConnectorInfoVOList;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user