From 702820e0b47460a513ed1fdefc8baeb54c4e3b32 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 28 Aug 2024 16:15:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E7=AB=AF=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=9F=A5=E8=AF=A2=E6=9E=AA?= =?UTF-8?q?=E5=8F=A3=E4=BF=A1=E6=81=AF=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessConnectorInfoController.java | 50 ++++++++++++++ .../service/PileConnectorInfoService.java | 3 +- .../impl/PileConnectorInfoServiceImpl.java | 68 +++++++++++++++++-- .../business/BusinessConnectorInfoVO.java | 14 ++-- 4 files changed, 122 insertions(+), 13 deletions(-) create mode 100644 jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessConnectorInfoController.java diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessConnectorInfoController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessConnectorInfoController.java new file mode 100644 index 000000000..421c687a6 --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessConnectorInfoController.java @@ -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; + } +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileConnectorInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileConnectorInfoService.java index db59dc586..d89f6d1ca 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileConnectorInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileConnectorInfoService.java @@ -7,6 +7,7 @@ import com.jsowell.pile.dto.QueryConnectorListDTO; import com.jsowell.pile.dto.UpdateConnectorParkNoDTO; import com.jsowell.pile.dto.business.QueryConnectorInfoDTO; import com.jsowell.pile.vo.base.ConnectorInfoVO; +import com.jsowell.pile.vo.uniapp.business.BusinessConnectorInfoVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import java.util.List; @@ -141,5 +142,5 @@ public interface PileConnectorInfoService { /** * 通过站点id和枪口状态查询枪口列表 */ - void getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto); + BusinessConnectorInfoVO getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java index 1199b15e2..998cc70de 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java @@ -27,6 +27,7 @@ import com.jsowell.pile.mapper.PileBasicInfoMapper; import com.jsowell.pile.mapper.PileConnectorInfoMapper; import com.jsowell.pile.service.*; 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.PileDetailVO; import com.jsowell.pile.vo.web.PileModelInfoVO; @@ -772,29 +773,84 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { } /** - * 批量获取枪口状态 + * 批量获取某状态的枪口数量 * @param pileConnectorCodeList * @return */ - private Map getConnectorStatus(List pileConnectorCodeList) { + private Map getConnectorStatus(List pileConnectorCodeList) { List 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) { String status = pileConnectorInfo.getStatus(); 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 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 - public void getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto) { + public BusinessConnectorInfoVO getConnectorListByStationAndStatus(QueryConnectorInfoDTO dto) { String stationId = dto.getStationId(); String connectorStatus = dto.getConnectorStatus(); int pageNum = dto.getPageNum(); int pageSize = dto.getPageSize(); + BusinessConnectorInfoVO vo = new BusinessConnectorInfoVO(); + // 根据站点id查询枪口列表(有缓存) + List uniAppConnectorList = getUniAppConnectorList(Long.parseLong(stationId)); + // 筛选出枪口编号 + List pileConnectorCodeList = uniAppConnectorList.stream() + .map(ConnectorInfoVO::getPileConnectorCode) + .collect(Collectors.toList()); + // 批量获取某状态的枪口数量 + Map 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和枪口状态查询枪口列表 QueryConnectorListDTO queryConnectorListDTO = QueryConnectorListDTO.builder() @@ -810,5 +866,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { .collect(Collectors.toList()); } + vo.setPileConnectorInfoVOList(pileConnectorInfoVOList); + return vo; } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/BusinessConnectorInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/BusinessConnectorInfoVO.java index 6d30195e1..6778e5cbb 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/BusinessConnectorInfoVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/BusinessConnectorInfoVO.java @@ -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 pileConnectorInfoVOList; } From f8f69e37e3d69fe46eb136970c1009920b919fbc Mon Sep 17 00:00:00 2001 From: Lemon Date: Thu, 29 Aug 2024 10:46:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?update=20=20=E6=8E=A5=E5=8F=A3=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/运营小程序接口文档.md | 81 +++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/doc/运营小程序接口文档.md b/doc/运营小程序接口文档.md index 92479368c..013559a40 100644 --- a/doc/运营小程序接口文档.md +++ b/doc/运营小程序接口文档.md @@ -189,36 +189,46 @@ # 站点充电实况列表 -接口地址: +接口地址:http://localhost:8080/business/pile/connector/getBusinessConnectorInfoList -请求方式: +请求方式:POST + +### 入参 + +| 字段名 | 类型 | 是否必传 | 备注 | +| --------------- | ------- | -------- | ------------------------------------------------------------ | +| stationId | String | Y | 站点id | +| connectorStatus | String | N | 枪口状态(0:离网 ;1:空闲;2:占用(未充电);3:占用(充电中);4:占用(预约锁定)即挂起 ;255:故障 | +| pageNum | Integer | N | 页码 | +| pageSize | Integer | N | 每页条数 | + +### 反参 + +| 字段名 | 类型 | 是否必传 | 备注 | +| ----------------------- | ------------------------- | -------- | -------------- | +| | | Y | 站点名称 | +| connectorNum | Integer | Y | 全部枪口数量 | +| chargingConnectorNum | Integer | Y | 充电中枪口数量 | +| freeConnectorNum | Integer | Y | 空闲枪口数量 | +| hangingConnectorNum | Integer | Y | 挂起枪口数量 | +| occupiedConnectorNum | Integer | Y | 占用枪口数量 | +| offlineConnectorNum | Integer | Y | 离线枪口数量 | +| faultConnectorNum | Integer | Y | 故障枪口数量 | +| pileConnectorInfoVOList | List | Y | 枪口信息数组 | + +### PileConnectorInfoVO + +| 字段名 | 类型 | 是否必传 | 备注 | +| ----------------- | ------ | -------- | -------------------------- | +| pileConnectorCode | String | Y | 充电枪编号 | +| SOC | String | Y | 充电中soc(%) | +| timeRemaining | String | Y | 充电中充满剩余时长(分钟) | +| chargingTime | String | Y | 已充时长 | +| faultReason | String | Y | 故障原因 | -入参 -| 字段名 | 类型 | 是否必传 | 备注 | -| ------ | ---- | -------- | ---- | -| | | | | -反参 -| 字段名 | 类型 | 是否必传 | 备注 | -| ------ | ---- | -------- | -------------------------- | -| | | Y | 站点名称 | -| | | Y | 全部枪口数量 | -| | | Y | 充电中枪口数量 | -| | | Y | 空闲枪口数量 | -| | | Y | 挂起枪口数量 | -| | | Y | 占用枪口数量 | -| | | Y | 离线枪口数量 | -| | | Y | 故障枪口数量 | -| | | Y | 充电枪编号 | -| | | Y | 充电中soc(%) | -| | | Y | 充电中充满剩余时长(分钟) | -| | | Y | 空闲时长(分钟) | -| | | Y | 挂起时长(分钟) | -| | | Y | 占用时长(分钟) | -| | | Y | 离线时长(分钟) | -| | | Y | 故障时长(分钟) | # 站点充电实况搜索 @@ -300,24 +310,6 @@ - - -1、预约充电结束时间不选择即为充满自停, - -2、充电中的数据下拉不刷新 - -3、预约充电显示预约状态(成功,预约中,失败) - -4、预约充电订单目前不显示实时充电数据 - -5、桩主需要能看到桩的实时状态 - - - - - - - 1、在 ==站点管理== ——> ==运营管理== 中勾选浙江省平台,点击保存按钮 image-20240816100744446 @@ -325,6 +317,3 @@ 2、在 ==三方平台管理== ——> ==对接第三方平台关系== 页面中找到浙江省平台,点击 ==同步数据==,找到对应站点,点击 ==打开推送菜单== 页面, 点击右侧 ==推送充电站信息变化== 右侧的 ==推送== 按钮 image-20240816100551217 - - -