From fc339b23fabd67758681ad8884331a35a82f1a8a Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Sat, 27 Dec 2025 16:09:47 +0800 Subject: [PATCH 1/6] =?UTF-8?q?update=E6=9F=A5=E8=AF=A2=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E7=BB=84=E4=B8=AD=E4=BC=9A=E5=91=98=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jsowell/pile/mapper/MemberGroupMapper.java | 2 +- .../pile/service/impl/MemberGroupServiceImpl.java | 5 ++++- .../resources/mapper/pile/MemberGroupMapper.xml | 14 ++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberGroupMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberGroupMapper.java index dd64d6c13..7d7475fd2 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberGroupMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberGroupMapper.java @@ -80,7 +80,7 @@ public interface MemberGroupMapper { MemberGroupVO queryByGroupCodeAndMemberId(@Param("groupCode") String groupCode, @Param("memberId") String memberId); - List queryMemberList(@Param("groupCode") String groupCode); + List queryMemberList(MemberGroupDTO dto); MemberGroup selectByGroupCode(String groupCode); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberGroupServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberGroupServiceImpl.java index e0a50aafc..7e18ed938 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberGroupServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberGroupServiceImpl.java @@ -386,7 +386,10 @@ public class MemberGroupServiceImpl implements MemberGroupService { @Override public List queryMemberList(MemberGroupDTO dto) { - List list = memberGroupMapper.queryMemberList(dto.getGroupCode()); + if (dto.getGroupCode().isEmpty()){ + return null; + } + List list = memberGroupMapper.queryMemberList(dto); return list; } diff --git a/jsowell-pile/src/main/resources/mapper/pile/MemberGroupMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/MemberGroupMapper.xml index cccf2984e..982fae8ed 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/MemberGroupMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/MemberGroupMapper.xml @@ -19,7 +19,7 @@ - + id, group_name, group_code, merchant_id, station_id, group_level, group_type, discount, create_by, create_time, update_by, update_time, del_flag @@ -165,8 +165,14 @@ FROM member_basic_info t1 JOIN member_group_relation t2 ON t2.member_id = t1.member_id and t2.del_flag = '0' - where - t2.group_code = #{groupCode,jdbcType=VARCHAR} + WHERE t1.del_flag = '0' + AND t2.group_code = #{groupCode} + + AND t1.mobile_number LIKE CONCAT('%', #{phoneNumber}, '%') + + + AND t2.member_id = #{memberId} + - \ No newline at end of file + From 47e8d0f844e6f22f5aa13b1a99867b6e6a61ca0d Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 29 Dec 2025 09:49:55 +0800 Subject: [PATCH 2/6] =?UTF-8?q?update=20=200x3b=E6=8E=A8=E9=80=81=E5=85=85?= =?UTF-8?q?=E7=94=B5=E7=AE=97=E6=B3=95=E5=8F=96=E6=B6=88=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TransactionRecordsRequestHandler.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/TransactionRecordsRequestHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/TransactionRecordsRequestHandler.java index 0a7a3ce8c..f96e15688 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/TransactionRecordsRequestHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/TransactionRecordsRequestHandler.java @@ -706,16 +706,16 @@ public class TransactionRecordsRequestHandler extends AbstractYkcHandler { }, thirdpartyTaskExecutor); // TODO 异步推送充电订单算法平台 - // CompletableFuture.runAsync(() -> { - // try { - // // 1-web端 - // getReportUrlByOrderCode(finalOrderBasicInfo.getOrderCode(), Constants.ONE); - // // 2-pdf端 - // getReportUrlByOrderCode(finalOrderBasicInfo.getOrderCode(), Constants.TWO); - // }catch (Exception e) { - // log.error("异步推送充电订单算法平台 error", e); - // } - // }, thirdpartyTaskExecutor); + CompletableFuture.runAsync(() -> { + try { + // 1-web端 + getReportUrlByOrderCode(finalOrderBasicInfo.getOrderCode(), Constants.ONE); + // 2-pdf端 + getReportUrlByOrderCode(finalOrderBasicInfo.getOrderCode(), Constants.TWO); + }catch (Exception e) { + log.error("异步推送充电订单算法平台 error", e); + } + }, thirdpartyTaskExecutor); // // // CompletableFuture.runAsync(() -> { From 38d0d05327b883845d4db2c8211c0d78d5cf1341 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Mon, 29 Dec 2025 14:41:22 +0800 Subject: [PATCH 3/6] =?UTF-8?q?bugfix:=20=E4=BC=9A=E5=91=98=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E7=9A=84=E9=94=81=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA60s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/jsowell/service/MemberService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/service/MemberService.java b/jsowell-admin/src/main/java/com/jsowell/service/MemberService.java index c8e14f756..15950f0b0 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/MemberService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/MemberService.java @@ -189,8 +189,8 @@ public class MemberService { String requestId = IdUtils.fastUUID(); Boolean isLock = false; try { - // 获取锁,防止注册创建重复账户,锁超时时间10秒 - isLock = redisCache.lock(lockKey, requestId, 10); + // 获取锁,防止注册创建重复账户,锁超时时间60秒(足够覆盖业务执行时间) + isLock = redisCache.lock(lockKey, requestId, 60); if (!isLock) { // 获取锁失败,说明有其他请求正在处理,提示用户稍候 log.warn("获取注册锁失败,可能有并发请求正在处理, phoneNumber:{}", phoneNumber); From fe80482e6bb7c23a955e2f4af25c5c3011736f90 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Wed, 31 Dec 2025 08:56:45 +0800 Subject: [PATCH 4/6] =?UTF-8?q?add=20=E6=96=B0=E5=A2=9E=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=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E5=8F=8A=E5=85=85=E7=94=B5=E6=9E=AA=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessStationInfoController.java | 22 +++ .../common/constant/CacheConstants.java | 5 + .../QueryStationWithConnectorStatusDTO.java | 39 +++++ .../pile/service/PileStationInfoService.java | 9 + .../impl/PileConnectorInfoServiceImpl.java | 17 ++ .../impl/PileStationInfoServiceImpl.java | 164 ++++++++++++++++++ .../jsowell/pile/vo/base/ConnectorInfoVO.java | 14 ++ .../StationWithConnectorStatusVO.java | 72 ++++++++ 8 files changed, 342 insertions(+) create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/dto/business/QueryStationWithConnectorStatusDTO.java create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusVO.java diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java index f78eca58a..787852b98 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java @@ -5,10 +5,12 @@ import com.google.common.collect.ImmutableMap; import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; +import com.jsowell.pile.dto.business.QueryStationWithConnectorStatusDTO; import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; import com.jsowell.pile.dto.business.StationStatisticsInfoDTO; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.PileStationInfoService; +import com.jsowell.common.core.page.PageResponse; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; import org.springframework.beans.factory.annotation.Autowired; @@ -151,4 +153,24 @@ public class BusinessStationInfoController extends BaseController { return response; } + /** + * 运营端小程序查询站点及充电枪状态 + * 支持通过站点ID或站点名称查询,不传则查询全部站点 + * @param dto 查询条件 + * @return 站点列表及充电枪状态统计 + */ + @PostMapping("/queryStationWithConnectorStatus") + public RestApiResponse queryStationWithConnectorStatus(@RequestBody QueryStationWithConnectorStatusDTO dto) { + RestApiResponse response = null; + try { + PageResponse pageResponse = pileStationInfoService.queryStationWithConnectorStatus(dto); + response = new RestApiResponse<>(pageResponse); + } 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-common/src/main/java/com/jsowell/common/constant/CacheConstants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java index efc2c6011..94b2e2495 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java @@ -335,6 +335,11 @@ public class CacheConstants { */ public static final String PILE_HARDWARE_FAULT = "pile_hardware_fault:"; + /** + * 充电枪状态变更时间戳(用于计算状态持续时长) + */ + public static final String PILE_CONNECTOR_STATUS_CHANGE_TIME = "pile_connector_status_change_time:"; + /** * 充电桩sn生成 key */ diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/business/QueryStationWithConnectorStatusDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/business/QueryStationWithConnectorStatusDTO.java new file mode 100644 index 000000000..558ce2d2c --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/business/QueryStationWithConnectorStatusDTO.java @@ -0,0 +1,39 @@ +package com.jsowell.pile.dto.business; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 运营端小程序查询站点及充电枪状态DTO + * + * @author Auto + * @Date 2024/12/19 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class QueryStationWithConnectorStatusDTO { + /** + * 站点id(可选) + */ + private String stationId; + + /** + * 站点名称(可选,支持模糊查询) + */ + private String stationName; + + /** + * 页码(默认1) + */ + private int pageNum; + + /** + * 每页条数(默认10) + */ + private int pageSize; +} + diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java index 4f006ed75..505686b68 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java @@ -6,6 +6,7 @@ import com.jsowell.pile.dto.FastCreateStationDTO; import com.jsowell.pile.dto.QueryStationDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.dto.amap.GetStationInfoDTO; +import com.jsowell.pile.dto.business.QueryStationWithConnectorStatusDTO; import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; import com.jsowell.pile.dto.business.StationStatisticsInfoDTO; import com.jsowell.pile.dto.lutongyunting.BindParkingPlatformDTO; @@ -14,6 +15,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; +import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.web.StationSelectVO; @@ -215,4 +217,11 @@ public interface PileStationInfoService { * @return */ PageResponse queryUserFrequentedStation(QueryStationDTO dto); + + /** + * 运营端小程序查询站点及充电枪状态 + * @param dto 查询条件 + * @return 站点列表及充电枪状态统计 + */ + PageResponse queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO 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 945554c51..b40d07787 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 @@ -773,6 +773,23 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { deleteRedisByPileSnOrPileConnectorCode(pileSn, pileConnectorCode); redisCache.setCacheObject(redisKey, status, CacheConstants.cache_expire_time_6m); + // 记录状态变更时间戳(用于计算状态持续时长) + // 只记录需要计算时长的状态:故障、离线、占用(未充电)、挂起(预约锁定) + if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.FAULT.getValue()) + || StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue()) + || StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue()) + || StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue())) { + String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; + String now = DateUtils.getDateTime(); + redisCache.setCacheObject(statusChangeTimeKey, now, CacheConstants.cache_expire_time_30d); + } else { + // 状态变更为空闲或充电中时,删除状态变更时间戳 + String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; + if (redisCache.hasKey(statusChangeTimeKey)) { + redisCache.deleteObject(statusChangeTimeKey); + } + } + // 异步放缓存 CompletableFuture.runAsync(() -> statusChange(pileConnectorCode), executor); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index 445a7540c..9d8e00693 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -16,11 +16,13 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.*; import com.jsowell.common.util.ip.AddressUtils; +import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.FastCreateStationDTO; import com.jsowell.pile.dto.QueryStationDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.dto.amap.GetStationInfoDTO; +import com.jsowell.pile.dto.business.QueryStationWithConnectorStatusDTO; import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; import com.jsowell.pile.dto.business.StationStatisticsInfoDTO; import com.jsowell.pile.dto.lutongyunting.BindParkingPlatformDTO; @@ -35,6 +37,7 @@ import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationOrderQuantityInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; +import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusVO; import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails; import com.jsowell.pile.vo.web.BillingTemplateVO; import com.jsowell.pile.vo.web.PileStationVO; @@ -1623,4 +1626,165 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { } return uniAppQueryStationInfoListV2(dto); } + + /** + * 运营端小程序查询站点及充电枪状态 + * @param dto 查询条件 + * @return 站点列表及充电枪状态统计 + */ + @Override + public PageResponse queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto) { + // 获取当前登录账号的运营商权限 + List merchantInfoVOList = UserUtils.getMerchantInfoVOList(); + if (CollectionUtils.isEmpty(merchantInfoVOList)) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + List merchantIds = merchantInfoVOList.stream() + .map(MerchantInfoVO::getMerchantId) + .collect(Collectors.toList()); + + // 根据权限查询站点列表 + List allStations = getStationInfosByMerchantIds(merchantIds); + if (CollectionUtils.isEmpty(allStations)) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + + // 根据站点ID或站点名称过滤 + List filteredStations = allStations; + if (StringUtils.isNotBlank(dto.getStationId())) { + filteredStations = allStations.stream() + .filter(s -> String.valueOf(s.getId()).equals(dto.getStationId())) + .collect(Collectors.toList()); + } else if (StringUtils.isNotBlank(dto.getStationName())) { + filteredStations = allStations.stream() + .filter(s -> s.getStationName() != null && s.getStationName().contains(dto.getStationName())) + .collect(Collectors.toList()); + } + + if (CollectionUtils.isEmpty(filteredStations)) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + + // 分页处理 + int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum(); + int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize(); + PageHelper.startPage(pageNum, pageSize); + + // 构建返回结果 + List resultList = new ArrayList<>(); + for (PileStationInfo station : filteredStations) { + String stationId = String.valueOf(station.getId()); + + // 查询站点下的所有充电枪 + List connectorList = pileConnectorInfoService.getUniAppConnectorList(Long.parseLong(stationId)); + + // 统计各状态数量并计算时长 + int totalNum = connectorList.size(); + int chargingNum = 0; // 充电中 + int freeNum = 0; // 空闲 + int occupiedNum = 0; // 占用(未充电) + int hangingNum = 0; // 挂起(预约锁定) + int offlineNum = 0; // 离线 + int faultNum = 0; // 故障 + + String now = DateUtils.getDateTime(); + for (ConnectorInfoVO connector : connectorList) { + String status = connector.getConnectorStatus(); + String pileConnectorCode = connector.getPileConnectorCode(); + + // 计算时长 + if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), status)) { + // 充电中:从实时数据中获取剩余时间 + chargingNum++; + OrderBasicInfo order = orderBasicInfoService.queryChargingByPileConnectorCode(pileConnectorCode); + if (order != null) { + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(order.getTransactionCode()); + if (CollectionUtils.isNotEmpty(chargingRealTimeData)) { + RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0); + connector.setTimeRemaining(realTimeMonitorData.getTimeRemaining()); // 剩余时长(分钟) + } + } + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FAULT.getValue(), status)) { + // 故障:从Redis中获取状态变更时间戳,计算从状态变更到现在的时间 + faultNum++; + String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; + String statusChangeTimeStr = redisCache.getCacheObject(statusChangeTimeKey); + if (StringUtils.isNotBlank(statusChangeTimeStr)) { + try { + long duration = DateUtils.intervalTime(statusChangeTimeStr, now); + connector.setDuration(String.valueOf(duration)); + } catch (Exception e) { + log.warn("计算状态持续时长失败, pileConnectorCode:{}, statusChangeTimeStr:{}", pileConnectorCode, statusChangeTimeStr, e); + } + } + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue(), status)) { + // 离线:从Redis中获取状态变更时间戳,计算从状态变更到现在的时间 + offlineNum++; + String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; + String statusChangeTimeStr = redisCache.getCacheObject(statusChangeTimeKey); + if (StringUtils.isNotBlank(statusChangeTimeStr)) { + try { + long duration = DateUtils.intervalTime(statusChangeTimeStr, now); + connector.setDuration(String.valueOf(duration)); + } catch (Exception e) { + log.warn("计算状态持续时长失败, pileConnectorCode:{}, statusChangeTimeStr:{}", pileConnectorCode, statusChangeTimeStr, e); + } + } + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) { + // 占用(未充电):从Redis中获取状态变更时间戳,计算从状态变更到现在的时间 + occupiedNum++; + String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; + String statusChangeTimeStr = redisCache.getCacheObject(statusChangeTimeKey); + if (StringUtils.isNotBlank(statusChangeTimeStr)) { + try { + long duration = DateUtils.intervalTime(statusChangeTimeStr, now); + connector.setDuration(String.valueOf(duration)); + } catch (Exception e) { + log.warn("计算状态持续时长失败, pileConnectorCode:{}, statusChangeTimeStr:{}", pileConnectorCode, statusChangeTimeStr, e); + } + } + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue(), status)) { + // 挂起(预约锁定):从Redis中获取状态变更时间戳,计算从状态变更到现在的时间 + hangingNum++; + String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; + String statusChangeTimeStr = redisCache.getCacheObject(statusChangeTimeKey); + if (StringUtils.isNotBlank(statusChangeTimeStr)) { + try { + long duration = DateUtils.intervalTime(statusChangeTimeStr, now); + connector.setDuration(String.valueOf(duration)); + } catch (Exception e) { + log.warn("计算状态持续时长失败, pileConnectorCode:{}, statusChangeTimeStr:{}", pileConnectorCode, statusChangeTimeStr, e); + } + } + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FREE.getValue(), status)) { + freeNum++; + } + } + + StationWithConnectorStatusVO vo = StationWithConnectorStatusVO.builder() + .stationId(stationId) + .stationName(station.getStationName()) + .connectorNum(totalNum) + .chargingConnectorNum(chargingNum) + .freeConnectorNum(freeNum) + .occupiedConnectorNum(occupiedNum) + .hangingConnectorNum(hangingNum) + .offlineConnectorNum(offlineNum) + .faultConnectorNum(faultNum) + .connectorList(connectorList) + .build(); + resultList.add(vo); + } + + + // 构建分页响应 + PageInfo pageInfo = new PageInfo<>(resultList); + return PageResponse.builder() + .pageNum(pageNum) + .pageSize(pageSize) + .total(pageInfo.getTotal()) + .pages(pageInfo.getPages()) + .list(resultList) + .build(); + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java index 5e4fa27ef..ae1fc5692 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java @@ -66,4 +66,18 @@ public class ConnectorInfoVO { */ private String ratedVoltage; + /** + * 状态更新时间(用于计算时长) + */ + private String updateTime; + + /** + * 剩余时长(充电中状态,单位:分钟) + */ + private String timeRemaining; + + /** + * 状态持续时长(故障/离线/占用/挂起状态,单位:分钟) + */ + private String duration; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusVO.java new file mode 100644 index 000000000..0815a8fa3 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusVO.java @@ -0,0 +1,72 @@ +package com.jsowell.pile.vo.uniapp.business; + +import com.jsowell.pile.vo.base.ConnectorInfoVO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 运营端小程序站点及充电枪状态VO + * + * @author Auto + * @Date 2024/12/19 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class StationWithConnectorStatusVO { + /** + * 站点id + */ + private String stationId; + + /** + * 站点名称 + */ + private String stationName; + + /** + * 总枪口数量 + */ + private Integer connectorNum; + + /** + * 充电中枪口数量 + */ + private Integer chargingConnectorNum; + + /** + * 空闲枪口数量 + */ + private Integer freeConnectorNum; + + /** + * 挂起枪口数量 + */ + private Integer hangingConnectorNum; + + /** + * 占用中枪口数量 + */ + private Integer occupiedConnectorNum; + + /** + * 离线枪口数量 + */ + private Integer offlineConnectorNum; + + /** + * 故障枪口数量 + */ + private Integer faultConnectorNum; + + /** + * 充电枪列表 + */ + private List connectorList; +} + From a20cf66987319db29a7735f27857a26394b7508d Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Wed, 31 Dec 2025 10:01:38 +0800 Subject: [PATCH 5/6] update --- .../BusinessStationInfoController.java | 6 +- .../pile/service/PileStationInfoService.java | 3 +- .../impl/PileStationInfoServiceImpl.java | 71 ++++++++++++++++--- .../StationWithConnectorStatusPageVO.java | 60 ++++++++++++++++ 4 files changed, 127 insertions(+), 13 deletions(-) create mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusPageVO.java diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java index 787852b98..d5db0692c 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java @@ -10,7 +10,7 @@ import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; import com.jsowell.pile.dto.business.StationStatisticsInfoDTO; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.PileStationInfoService; -import com.jsowell.common.core.page.PageResponse; +import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusPageVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; import org.springframework.beans.factory.annotation.Autowired; @@ -163,8 +163,8 @@ public class BusinessStationInfoController extends BaseController { public RestApiResponse queryStationWithConnectorStatus(@RequestBody QueryStationWithConnectorStatusDTO dto) { RestApiResponse response = null; try { - PageResponse pageResponse = pileStationInfoService.queryStationWithConnectorStatus(dto); - response = new RestApiResponse<>(pageResponse); + StationWithConnectorStatusPageVO result = pileStationInfoService.queryStationWithConnectorStatus(dto); + response = new RestApiResponse<>(result); } catch (Exception e) { logger.error("查询站点及充电枪状态 error", e); response = new RestApiResponse<>(e); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java index 505686b68..581a5e4e8 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java @@ -15,6 +15,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; +import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusPageVO; import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.web.StationSelectVO; @@ -223,5 +224,5 @@ public interface PileStationInfoService { * @param dto 查询条件 * @return 站点列表及充电枪状态统计 */ - PageResponse queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto); + StationWithConnectorStatusPageVO queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index 9d8e00693..b616ba596 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -37,6 +37,7 @@ import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationOrderQuantityInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; +import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusPageVO; import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusVO; import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails; import com.jsowell.pile.vo.web.BillingTemplateVO; @@ -1630,10 +1631,10 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { /** * 运营端小程序查询站点及充电枪状态 * @param dto 查询条件 - * @return 站点列表及充电枪状态统计 + * @return 站点列表及充电枪状态统计(包含总统计) */ @Override - public PageResponse queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto) { + public StationWithConnectorStatusPageVO queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto) { // 获取当前登录账号的运营商权限 List merchantInfoVOList = UserUtils.getMerchantInfoVOList(); if (CollectionUtils.isEmpty(merchantInfoVOList)) { @@ -1665,14 +1666,49 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); } - // 分页处理 + // 先统计所有站点的总枪口数量(用于前端不传站点时显示总计) + int totalConnectorNum = 0; // 总枪口数量 + int totalChargingNum = 0; // 总充电中数量 + int totalFreeNum = 0; // 总空闲数量 + int totalOccupiedNum = 0; // 总占用(未充电)数量 + int totalHangingNum = 0; // 总挂起(预约锁定)数量 + int totalOfflineNum = 0; // 总离线数量 + int totalFaultNum = 0; // 总故障数量 + + // 统计所有站点的枪口数量(不计算时长,只统计数量) + for (PileStationInfo station : filteredStations) { + String stationId = String.valueOf(station.getId()); + List allConnectorList = pileConnectorInfoService.getUniAppConnectorList(Long.parseLong(stationId)); + totalConnectorNum += allConnectorList.size(); + for (ConnectorInfoVO connector : allConnectorList) { + String status = connector.getConnectorStatus(); + if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), status)) { + totalChargingNum++; + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FREE.getValue(), status)) { + totalFreeNum++; + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) { + totalOccupiedNum++; + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue(), status)) { + totalHangingNum++; + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue(), status)) { + totalOfflineNum++; + } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FAULT.getValue(), status)) { + totalFaultNum++; + } + } + } + + // 分页处理(手动分页,避免PageHelper影响后续查询) int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum(); int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize(); - PageHelper.startPage(pageNum, pageSize); + int total = filteredStations.size(); + int start = (pageNum - 1) * pageSize; + int end = Math.min(start + pageSize, total); + List pagedStations = start < total ? filteredStations.subList(start, end) : new ArrayList<>(); // 构建返回结果 List resultList = new ArrayList<>(); - for (PileStationInfo station : filteredStations) { + for (PileStationInfo station : pagedStations) { String stationId = String.valueOf(station.getId()); // 查询站点下的所有充电枪 @@ -1696,6 +1732,8 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), status)) { // 充电中:从实时数据中获取剩余时间 chargingNum++; + // 清除分页参数,避免影响queryChargingByPileConnectorCode查询(该查询已有limit 1) + PageHelper.clearPage(); OrderBasicInfo order = orderBasicInfoService.queryChargingByPileConnectorCode(pileConnectorCode); if (order != null) { List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(order.getTransactionCode()); @@ -1777,14 +1815,29 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { } + // 清除分页参数,避免影响后续查询 + PageHelper.clearPage(); + // 构建分页响应 - PageInfo pageInfo = new PageInfo<>(resultList); - return PageResponse.builder() + int totalPages = (total + pageSize - 1) / pageSize; + PageResponse pageResponse = PageResponse.builder() .pageNum(pageNum) .pageSize(pageSize) - .total(pageInfo.getTotal()) - .pages(pageInfo.getPages()) + .total((long) total) + .pages(totalPages) .list(resultList) .build(); + + // 构建包含总统计的响应 + return StationWithConnectorStatusPageVO.builder() + .pageResponse(pageResponse) + .totalConnectorNum(totalConnectorNum) + .totalChargingConnectorNum(totalChargingNum) + .totalFreeConnectorNum(totalFreeNum) + .totalOccupiedConnectorNum(totalOccupiedNum) + .totalHangingConnectorNum(totalHangingNum) + .totalOfflineConnectorNum(totalOfflineNum) + .totalFaultConnectorNum(totalFaultNum) + .build(); } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusPageVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusPageVO.java new file mode 100644 index 000000000..2c7e1fa7f --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusPageVO.java @@ -0,0 +1,60 @@ +package com.jsowell.pile.vo.uniapp.business; + +import com.jsowell.common.core.page.PageResponse; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 运营端小程序站点及充电枪状态分页VO(包含总统计) + * + * @author Auto + * @Date 2024/12/19 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class StationWithConnectorStatusPageVO { + /** + * 分页数据 + */ + private PageResponse pageResponse; + + /** + * 总枪口数量(所有站点的总计) + */ + private Integer totalConnectorNum; + + /** + * 总充电中枪口数量 + */ + private Integer totalChargingConnectorNum; + + /** + * 总空闲枪口数量 + */ + private Integer totalFreeConnectorNum; + + /** + * 总占用中枪口数量(未充电) + */ + private Integer totalOccupiedConnectorNum; + + /** + * 总挂起枪口数量(预约锁定) + */ + private Integer totalHangingConnectorNum; + + /** + * 总离线枪口数量 + */ + private Integer totalOfflineConnectorNum; + + /** + * 总故障枪口数量 + */ + private Integer totalFaultConnectorNum; +} + From 7e2f9a4c61d61dbd92df965eb48112ce21e7dd8a Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Wed, 31 Dec 2025 11:47:44 +0800 Subject: [PATCH 6/6] update --- .../BusinessStationInfoController.java | 21 -- .../common/constant/CacheConstants.java | 4 - .../QueryStationWithConnectorStatusDTO.java | 39 ---- .../pile/service/PileStationInfoService.java | 10 +- .../impl/PileConnectorInfoServiceImpl.java | 16 -- .../impl/PileStationInfoServiceImpl.java | 217 ------------------ .../jsowell/pile/vo/base/ConnectorInfoVO.java | 14 -- .../StationWithConnectorStatusPageVO.java | 60 ----- .../StationWithConnectorStatusVO.java | 72 ------ 9 files changed, 1 insertion(+), 452 deletions(-) delete mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/dto/business/QueryStationWithConnectorStatusDTO.java delete mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusPageVO.java delete mode 100644 jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusVO.java diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java index d5db0692c..c4cdf9a86 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/business/BusinessStationInfoController.java @@ -5,12 +5,10 @@ import com.google.common.collect.ImmutableMap; import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; -import com.jsowell.pile.dto.business.QueryStationWithConnectorStatusDTO; import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; import com.jsowell.pile.dto.business.StationStatisticsInfoDTO; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.PileStationInfoService; -import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusPageVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; import org.springframework.beans.factory.annotation.Autowired; @@ -153,24 +151,5 @@ public class BusinessStationInfoController extends BaseController { return response; } - /** - * 运营端小程序查询站点及充电枪状态 - * 支持通过站点ID或站点名称查询,不传则查询全部站点 - * @param dto 查询条件 - * @return 站点列表及充电枪状态统计 - */ - @PostMapping("/queryStationWithConnectorStatus") - public RestApiResponse queryStationWithConnectorStatus(@RequestBody QueryStationWithConnectorStatusDTO dto) { - RestApiResponse response = null; - try { - StationWithConnectorStatusPageVO result = pileStationInfoService.queryStationWithConnectorStatus(dto); - response = new RestApiResponse<>(result); - } 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-common/src/main/java/com/jsowell/common/constant/CacheConstants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java index 94b2e2495..f7412bf96 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java @@ -335,10 +335,6 @@ public class CacheConstants { */ public static final String PILE_HARDWARE_FAULT = "pile_hardware_fault:"; - /** - * 充电枪状态变更时间戳(用于计算状态持续时长) - */ - public static final String PILE_CONNECTOR_STATUS_CHANGE_TIME = "pile_connector_status_change_time:"; /** * 充电桩sn生成 key diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/business/QueryStationWithConnectorStatusDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/business/QueryStationWithConnectorStatusDTO.java deleted file mode 100644 index 558ce2d2c..000000000 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/business/QueryStationWithConnectorStatusDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.jsowell.pile.dto.business; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 运营端小程序查询站点及充电枪状态DTO - * - * @author Auto - * @Date 2024/12/19 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class QueryStationWithConnectorStatusDTO { - /** - * 站点id(可选) - */ - private String stationId; - - /** - * 站点名称(可选,支持模糊查询) - */ - private String stationName; - - /** - * 页码(默认1) - */ - private int pageNum; - - /** - * 每页条数(默认10) - */ - private int pageSize; -} - diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java index 581a5e4e8..139cd9a5b 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileStationInfoService.java @@ -6,7 +6,6 @@ import com.jsowell.pile.dto.FastCreateStationDTO; import com.jsowell.pile.dto.QueryStationDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.dto.amap.GetStationInfoDTO; -import com.jsowell.pile.dto.business.QueryStationWithConnectorStatusDTO; import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; import com.jsowell.pile.dto.business.StationStatisticsInfoDTO; import com.jsowell.pile.dto.lutongyunting.BindParkingPlatformDTO; @@ -15,8 +14,6 @@ import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; -import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusPageVO; -import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.web.StationSelectVO; @@ -219,10 +216,5 @@ public interface PileStationInfoService { */ PageResponse queryUserFrequentedStation(QueryStationDTO dto); - /** - * 运营端小程序查询站点及充电枪状态 - * @param dto 查询条件 - * @return 站点列表及充电枪状态统计 - */ - StationWithConnectorStatusPageVO queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO 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 b40d07787..f6c5902ea 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 @@ -773,22 +773,6 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { deleteRedisByPileSnOrPileConnectorCode(pileSn, pileConnectorCode); redisCache.setCacheObject(redisKey, status, CacheConstants.cache_expire_time_6m); - // 记录状态变更时间戳(用于计算状态持续时长) - // 只记录需要计算时长的状态:故障、离线、占用(未充电)、挂起(预约锁定) - if (StringUtils.equals(status, PileConnectorDataBaseStatusEnum.FAULT.getValue()) - || StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue()) - || StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue()) - || StringUtils.equals(status, PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue())) { - String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; - String now = DateUtils.getDateTime(); - redisCache.setCacheObject(statusChangeTimeKey, now, CacheConstants.cache_expire_time_30d); - } else { - // 状态变更为空闲或充电中时,删除状态变更时间戳 - String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; - if (redisCache.hasKey(statusChangeTimeKey)) { - redisCache.deleteObject(statusChangeTimeKey); - } - } // 异步放缓存 CompletableFuture.runAsync(() -> statusChange(pileConnectorCode), executor); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index b616ba596..82511f0a9 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -16,13 +16,11 @@ import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.*; import com.jsowell.common.util.ip.AddressUtils; -import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.FastCreateStationDTO; import com.jsowell.pile.dto.QueryStationDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.dto.amap.GetStationInfoDTO; -import com.jsowell.pile.dto.business.QueryStationWithConnectorStatusDTO; import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; import com.jsowell.pile.dto.business.StationStatisticsInfoDTO; import com.jsowell.pile.dto.lutongyunting.BindParkingPlatformDTO; @@ -37,10 +35,7 @@ import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO; import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO; import com.jsowell.pile.vo.uniapp.business.StationOrderQuantityInfoVO; import com.jsowell.pile.vo.uniapp.business.StationStatisticsInfosVO; -import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusPageVO; -import com.jsowell.pile.vo.uniapp.business.StationWithConnectorStatusVO; import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails; -import com.jsowell.pile.vo.web.BillingTemplateVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.web.StationSelectVO; import com.jsowell.system.service.SysDeptService; @@ -1628,216 +1623,4 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { return uniAppQueryStationInfoListV2(dto); } - /** - * 运营端小程序查询站点及充电枪状态 - * @param dto 查询条件 - * @return 站点列表及充电枪状态统计(包含总统计) - */ - @Override - public StationWithConnectorStatusPageVO queryStationWithConnectorStatus(QueryStationWithConnectorStatusDTO dto) { - // 获取当前登录账号的运营商权限 - List merchantInfoVOList = UserUtils.getMerchantInfoVOList(); - if (CollectionUtils.isEmpty(merchantInfoVOList)) { - throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); - } - List merchantIds = merchantInfoVOList.stream() - .map(MerchantInfoVO::getMerchantId) - .collect(Collectors.toList()); - - // 根据权限查询站点列表 - List allStations = getStationInfosByMerchantIds(merchantIds); - if (CollectionUtils.isEmpty(allStations)) { - throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); - } - - // 根据站点ID或站点名称过滤 - List filteredStations = allStations; - if (StringUtils.isNotBlank(dto.getStationId())) { - filteredStations = allStations.stream() - .filter(s -> String.valueOf(s.getId()).equals(dto.getStationId())) - .collect(Collectors.toList()); - } else if (StringUtils.isNotBlank(dto.getStationName())) { - filteredStations = allStations.stream() - .filter(s -> s.getStationName() != null && s.getStationName().contains(dto.getStationName())) - .collect(Collectors.toList()); - } - - if (CollectionUtils.isEmpty(filteredStations)) { - throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); - } - - // 先统计所有站点的总枪口数量(用于前端不传站点时显示总计) - int totalConnectorNum = 0; // 总枪口数量 - int totalChargingNum = 0; // 总充电中数量 - int totalFreeNum = 0; // 总空闲数量 - int totalOccupiedNum = 0; // 总占用(未充电)数量 - int totalHangingNum = 0; // 总挂起(预约锁定)数量 - int totalOfflineNum = 0; // 总离线数量 - int totalFaultNum = 0; // 总故障数量 - - // 统计所有站点的枪口数量(不计算时长,只统计数量) - for (PileStationInfo station : filteredStations) { - String stationId = String.valueOf(station.getId()); - List allConnectorList = pileConnectorInfoService.getUniAppConnectorList(Long.parseLong(stationId)); - totalConnectorNum += allConnectorList.size(); - for (ConnectorInfoVO connector : allConnectorList) { - String status = connector.getConnectorStatus(); - if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), status)) { - totalChargingNum++; - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FREE.getValue(), status)) { - totalFreeNum++; - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) { - totalOccupiedNum++; - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue(), status)) { - totalHangingNum++; - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue(), status)) { - totalOfflineNum++; - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FAULT.getValue(), status)) { - totalFaultNum++; - } - } - } - - // 分页处理(手动分页,避免PageHelper影响后续查询) - int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum(); - int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize(); - int total = filteredStations.size(); - int start = (pageNum - 1) * pageSize; - int end = Math.min(start + pageSize, total); - List pagedStations = start < total ? filteredStations.subList(start, end) : new ArrayList<>(); - - // 构建返回结果 - List resultList = new ArrayList<>(); - for (PileStationInfo station : pagedStations) { - String stationId = String.valueOf(station.getId()); - - // 查询站点下的所有充电枪 - List connectorList = pileConnectorInfoService.getUniAppConnectorList(Long.parseLong(stationId)); - - // 统计各状态数量并计算时长 - int totalNum = connectorList.size(); - int chargingNum = 0; // 充电中 - int freeNum = 0; // 空闲 - int occupiedNum = 0; // 占用(未充电) - int hangingNum = 0; // 挂起(预约锁定) - int offlineNum = 0; // 离线 - int faultNum = 0; // 故障 - - String now = DateUtils.getDateTime(); - for (ConnectorInfoVO connector : connectorList) { - String status = connector.getConnectorStatus(); - String pileConnectorCode = connector.getPileConnectorCode(); - - // 计算时长 - if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), status)) { - // 充电中:从实时数据中获取剩余时间 - chargingNum++; - // 清除分页参数,避免影响queryChargingByPileConnectorCode查询(该查询已有limit 1) - PageHelper.clearPage(); - OrderBasicInfo order = orderBasicInfoService.queryChargingByPileConnectorCode(pileConnectorCode); - if (order != null) { - List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(order.getTransactionCode()); - if (CollectionUtils.isNotEmpty(chargingRealTimeData)) { - RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0); - connector.setTimeRemaining(realTimeMonitorData.getTimeRemaining()); // 剩余时长(分钟) - } - } - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FAULT.getValue(), status)) { - // 故障:从Redis中获取状态变更时间戳,计算从状态变更到现在的时间 - faultNum++; - String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; - String statusChangeTimeStr = redisCache.getCacheObject(statusChangeTimeKey); - if (StringUtils.isNotBlank(statusChangeTimeStr)) { - try { - long duration = DateUtils.intervalTime(statusChangeTimeStr, now); - connector.setDuration(String.valueOf(duration)); - } catch (Exception e) { - log.warn("计算状态持续时长失败, pileConnectorCode:{}, statusChangeTimeStr:{}", pileConnectorCode, statusChangeTimeStr, e); - } - } - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue(), status)) { - // 离线:从Redis中获取状态变更时间戳,计算从状态变更到现在的时间 - offlineNum++; - String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; - String statusChangeTimeStr = redisCache.getCacheObject(statusChangeTimeKey); - if (StringUtils.isNotBlank(statusChangeTimeStr)) { - try { - long duration = DateUtils.intervalTime(statusChangeTimeStr, now); - connector.setDuration(String.valueOf(duration)); - } catch (Exception e) { - log.warn("计算状态持续时长失败, pileConnectorCode:{}, statusChangeTimeStr:{}", pileConnectorCode, statusChangeTimeStr, e); - } - } - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) { - // 占用(未充电):从Redis中获取状态变更时间戳,计算从状态变更到现在的时间 - occupiedNum++; - String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; - String statusChangeTimeStr = redisCache.getCacheObject(statusChangeTimeKey); - if (StringUtils.isNotBlank(statusChangeTimeStr)) { - try { - long duration = DateUtils.intervalTime(statusChangeTimeStr, now); - connector.setDuration(String.valueOf(duration)); - } catch (Exception e) { - log.warn("计算状态持续时长失败, pileConnectorCode:{}, statusChangeTimeStr:{}", pileConnectorCode, statusChangeTimeStr, e); - } - } - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue(), status)) { - // 挂起(预约锁定):从Redis中获取状态变更时间戳,计算从状态变更到现在的时间 - hangingNum++; - String statusChangeTimeKey = CacheConstants.PILE_CONNECTOR_STATUS_CHANGE_TIME + pileConnectorCode; - String statusChangeTimeStr = redisCache.getCacheObject(statusChangeTimeKey); - if (StringUtils.isNotBlank(statusChangeTimeStr)) { - try { - long duration = DateUtils.intervalTime(statusChangeTimeStr, now); - connector.setDuration(String.valueOf(duration)); - } catch (Exception e) { - log.warn("计算状态持续时长失败, pileConnectorCode:{}, statusChangeTimeStr:{}", pileConnectorCode, statusChangeTimeStr, e); - } - } - } else if (StringUtils.equals(PileConnectorDataBaseStatusEnum.FREE.getValue(), status)) { - freeNum++; - } - } - - StationWithConnectorStatusVO vo = StationWithConnectorStatusVO.builder() - .stationId(stationId) - .stationName(station.getStationName()) - .connectorNum(totalNum) - .chargingConnectorNum(chargingNum) - .freeConnectorNum(freeNum) - .occupiedConnectorNum(occupiedNum) - .hangingConnectorNum(hangingNum) - .offlineConnectorNum(offlineNum) - .faultConnectorNum(faultNum) - .connectorList(connectorList) - .build(); - resultList.add(vo); - } - - - // 清除分页参数,避免影响后续查询 - PageHelper.clearPage(); - - // 构建分页响应 - int totalPages = (total + pageSize - 1) / pageSize; - PageResponse pageResponse = PageResponse.builder() - .pageNum(pageNum) - .pageSize(pageSize) - .total((long) total) - .pages(totalPages) - .list(resultList) - .build(); - - // 构建包含总统计的响应 - return StationWithConnectorStatusPageVO.builder() - .pageResponse(pageResponse) - .totalConnectorNum(totalConnectorNum) - .totalChargingConnectorNum(totalChargingNum) - .totalFreeConnectorNum(totalFreeNum) - .totalOccupiedConnectorNum(totalOccupiedNum) - .totalHangingConnectorNum(totalHangingNum) - .totalOfflineConnectorNum(totalOfflineNum) - .totalFaultConnectorNum(totalFaultNum) - .build(); - } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java index ae1fc5692..5e4fa27ef 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java @@ -66,18 +66,4 @@ public class ConnectorInfoVO { */ private String ratedVoltage; - /** - * 状态更新时间(用于计算时长) - */ - private String updateTime; - - /** - * 剩余时长(充电中状态,单位:分钟) - */ - private String timeRemaining; - - /** - * 状态持续时长(故障/离线/占用/挂起状态,单位:分钟) - */ - private String duration; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusPageVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusPageVO.java deleted file mode 100644 index 2c7e1fa7f..000000000 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusPageVO.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.jsowell.pile.vo.uniapp.business; - -import com.jsowell.common.core.page.PageResponse; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 运营端小程序站点及充电枪状态分页VO(包含总统计) - * - * @author Auto - * @Date 2024/12/19 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class StationWithConnectorStatusPageVO { - /** - * 分页数据 - */ - private PageResponse pageResponse; - - /** - * 总枪口数量(所有站点的总计) - */ - private Integer totalConnectorNum; - - /** - * 总充电中枪口数量 - */ - private Integer totalChargingConnectorNum; - - /** - * 总空闲枪口数量 - */ - private Integer totalFreeConnectorNum; - - /** - * 总占用中枪口数量(未充电) - */ - private Integer totalOccupiedConnectorNum; - - /** - * 总挂起枪口数量(预约锁定) - */ - private Integer totalHangingConnectorNum; - - /** - * 总离线枪口数量 - */ - private Integer totalOfflineConnectorNum; - - /** - * 总故障枪口数量 - */ - private Integer totalFaultConnectorNum; -} - diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusVO.java deleted file mode 100644 index 0815a8fa3..000000000 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/uniapp/business/StationWithConnectorStatusVO.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.jsowell.pile.vo.uniapp.business; - -import com.jsowell.pile.vo.base.ConnectorInfoVO; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -/** - * 运营端小程序站点及充电枪状态VO - * - * @author Auto - * @Date 2024/12/19 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class StationWithConnectorStatusVO { - /** - * 站点id - */ - private String stationId; - - /** - * 站点名称 - */ - private String stationName; - - /** - * 总枪口数量 - */ - private Integer connectorNum; - - /** - * 充电中枪口数量 - */ - private Integer chargingConnectorNum; - - /** - * 空闲枪口数量 - */ - private Integer freeConnectorNum; - - /** - * 挂起枪口数量 - */ - private Integer hangingConnectorNum; - - /** - * 占用中枪口数量 - */ - private Integer occupiedConnectorNum; - - /** - * 离线枪口数量 - */ - private Integer offlineConnectorNum; - - /** - * 故障枪口数量 - */ - private Integer faultConnectorNum; - - /** - * 充电枪列表 - */ - private List connectorList; -} -