diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java index 5224e068e..42877c830 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java @@ -3,15 +3,21 @@ package com.jsowell.api.thirdparty; import com.alibaba.fastjson2.JSON; import com.jsowell.common.annotation.Anonymous; +import com.jsowell.common.dto.thirdparty.JCTCommonParamsDTO; +import com.jsowell.common.dto.thirdparty.JCTPushRealTimeInfoDTO; +import com.jsowell.common.dto.thirdparty.JCTQueryStationInfoDTO; import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; +import com.jsowell.common.service.ThirdPartyService; +import com.jsowell.common.util.bean.BeanUtils; import com.jsowell.pile.dto.*; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.thirdparty.platform.dto.RetryOrderDTO; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.*; @@ -35,6 +41,10 @@ public class ChangZhouController extends ThirdPartyBaseController { @Qualifier("changZhouPlatformServiceImpl") private ThirdPartyPlatformService platformLogic; + @DubboReference(group = "third", version = "1.0.0", timeout = 10000) + private ThirdPartyService thirdPartyService; + + /** * getToken @@ -43,8 +53,15 @@ public class ChangZhouController extends ThirdPartyBaseController { public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { logger.info("{}-请求令牌 params:{}" , platformName , JSON.toJSONString(dto)); try { - // Map map = zdlService.generateToken(dto); - Map map = platformLogic.queryToken(dto); +// Map map = platformLogic.queryToken(dto); + + // 新方法 + JCTCommonParamsDTO jctCommonParamsDTO = new JCTCommonParamsDTO(); + BeanUtils.copyProperties(dto, jctCommonParamsDTO); + jctCommonParamsDTO.setPlatformType(platformType); + logger.info("请求参数转换后:{}" , JSON.toJSONString(jctCommonParamsDTO)); + Map map = thirdPartyService.queryToken(jctCommonParamsDTO); + logger.info("{}-请求令牌 result:{}" , platformName , map); return CommonResult.success(0 , "请求令牌成功!" , map.get("Data") , map.get("Sig")); } catch (Exception e) { @@ -78,8 +95,15 @@ public class ChangZhouController extends ThirdPartyBaseController { // 解析入参 QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto , QueryStationInfoDTO.class); + JCTQueryStationInfoDTO jctQueryStationInfoDTO = new JCTQueryStationInfoDTO(); + BeanUtils.copyProperties(queryStationInfoDTO, jctQueryStationInfoDTO); + jctQueryStationInfoDTO.setPlatformType(platformType); + logger.info("请求参数转换后:{}" , JSON.toJSONString(jctQueryStationInfoDTO)); // 执行逻辑 - Map map = platformLogic.queryStationsInfo(queryStationInfoDTO); + Map map = thirdPartyService.queryStationsInfo(jctQueryStationInfoDTO); + + // 执行逻辑 +// Map map = platformLogic.queryStationsInfo(queryStationInfoDTO); logger.info("{}-查询充电站信息 result:{}" , platformName , JSON.toJSONString(map)); return CommonResult.success(0 , "查询充电站信息成功!" , map.get("Data") , map.get("Sig")); } catch (Exception e) { @@ -100,7 +124,14 @@ public class ChangZhouController extends ThirdPartyBaseController { public RestApiResponse notification_stationStatus(@RequestBody PushRealTimeInfoDTO pushRealTimeInfoDTO , HttpServletRequest request) { RestApiResponse response = null; try { - String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO); +// String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO); + + JCTPushRealTimeInfoDTO jctPushRealTimeInfoDTO = new JCTPushRealTimeInfoDTO(); + BeanUtils.copyProperties(pushRealTimeInfoDTO, jctPushRealTimeInfoDTO); + jctPushRealTimeInfoDTO.setPlatformType(platformType); + logger.info("请求参数转换后:{}" , JSON.toJSONString(jctPushRealTimeInfoDTO)); + Map result = thirdPartyService.notificationStationStatus(jctPushRealTimeInfoDTO); + logger.info("【{}】推送设备状态 result:{}" , this.getClass().getSimpleName() , result); response = new RestApiResponse<>(result); } catch (BusinessException e) { diff --git a/jsowell-admin/src/main/java/com/jsowell/service/TempService.java b/jsowell-admin/src/main/java/com/jsowell/service/TempService.java index 3c29cfe82..ef10b9670 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/TempService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/TempService.java @@ -1281,82 +1281,98 @@ public class TempService { * @return */ public OrderCountByTimeVO queryOrderCountByTime(QueryOrderDTO dto) { - // 处理时间默认值 if (dto == null) { dto = new QueryOrderDTO(); } - // 如果开始时间为空,则默认为当天开始时间 - if (dto.getStartTime() == null || dto.getStartTime().isEmpty()) { - LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); - dto.setStartTime(todayStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - } - - // 如果结束时间为空,则默认为当前时间 - if (dto.getEndTime() == null || dto.getEndTime().isEmpty()) { - dto.setEndTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - } - - //条件查询订单 - List orderListVOS = orderBasicInfoMapper.selectOrderBasicInfoList(dto); - - //统计订单 - List result = new ArrayList<>(); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD_HH_MM_SS); - try { - // 将开始时间和结束时间转换为LocalDateTime类型 - LocalDateTime queryStartTime = LocalDateTime.parse(dto.getStartTime(), dateTimeFormatter); - LocalDateTime queryEndTime = LocalDateTime.parse(dto.getEndTime(), dateTimeFormatter); + // 开始时间默认:当天零点 + if (StringUtils.isEmpty(dto.getStartTime())) { + LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); + dto.setStartTime(todayStart.format(dateTimeFormatter)); + } + + // 结束时间默认:当前时间 + if (StringUtils.isEmpty(dto.getEndTime())) { + dto.setEndTime(LocalDateTime.now().format(dateTimeFormatter)); + } + + // ====== 查询订单数据 ====== + List orderList = orderBasicInfoMapper.selectOrderBasicInfoList(dto); + + // ====== 统计逻辑 ====== + List result = new ArrayList<>(); + BigDecimal totalInsuranceAmount = BigDecimal.ZERO; // 总保险金额 + + try { + // 转换查询时间 + LocalDateTime queryStart = LocalDateTime.parse(dto.getStartTime(), dateTimeFormatter); + LocalDateTime queryEnd = LocalDateTime.parse(dto.getEndTime(), dateTimeFormatter); // 按小时分组订单 - Map> ordersByHour = orderListVOS.stream() + Map> ordersByHour = orderList.stream() .collect(Collectors.groupingBy(order -> { - LocalDateTime createTime; - // 如果订单创建时间为空,则默认为当前时间 if (order.getCreateTime() != null) { - createTime = LocalDateTime.parse((String) order.getCreateTime(), dateTimeFormatter); + return LocalDateTime.parse(order.getCreateTime() , dateTimeFormatter) + .withMinute(0).withSecond(0).withNano(0); } else { logger.warn("订单创建时间为空,订单号:{}", order.getOrderCode()); - return LocalDateTime.now(); + return LocalDateTime.now().withMinute(0).withSecond(0).withNano(0); } - // 将订单创建时间按小时分组 - return createTime.withMinute(0).withSecond(0).withNano(0); })); - - // 从开始时间开始,按小时统计订单数量 - LocalDateTime currentHour = queryStartTime.withMinute(0).withSecond(0).withNano(0); - while (currentHour.isBefore(queryEndTime)) { - // 查询当前小时订单数量 + // 从开始时间到结束时间,逐小时统计 + LocalDateTime currentHour = queryStart.withMinute(0).withSecond(0).withNano(0); + while (currentHour.isBefore(queryEnd)) { LocalDateTime nextHour = currentHour.plusHours(1); - int count = ordersByHour.getOrDefault(currentHour, Collections.emptyList()).size(); + // 当前小时的订单集合 + List ordersInHour = ordersByHour.getOrDefault(currentHour, Collections.emptyList()); + int count = ordersInHour.size(); + + // 统计该小时保险金额 + BigDecimal hourInsuranceAmount = ordersInHour.stream() + .map(OrderListVO::getInsuranceAmount) // 假设 VO 里有该字段 + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 封装结果 OrderCountByTimeVO.OrderCountByTimeListVO vo = new OrderCountByTimeVO.OrderCountByTimeListVO(); vo.setStartTime(currentHour.format(dateTimeFormatter)); vo.setEndTime(nextHour.format(dateTimeFormatter)); vo.setCount(count); vo.setOrderCount(count); + vo.setInsuranceAmount(hourInsuranceAmount); + result.add(vo); + // 累加总保险金额 + totalInsuranceAmount = totalInsuranceAmount.add(hourInsuranceAmount); + currentHour = nextHour; } - // 按开始时间排序 + // 排序(确保结果有序) result.sort(Comparator.comparing(OrderCountByTimeVO.OrderCountByTimeListVO::getStartTime)); + } catch (Exception e) { logger.error("统计订单数量失败", e); } - logger.info("查询订单数量结果:{}", JSONObject.toJSONString(result)); + + // ====== 封装返回结果 ====== OrderCountByTimeVO orderCountByTimeVO = new OrderCountByTimeVO(); orderCountByTimeVO.setOrderCountByTimeList(result); - //订单总数 - Integer totalCount = 0; + // 计算总订单数 + int totalCount = 0; for (OrderCountByTimeVO.OrderCountByTimeListVO vo : result) { totalCount += vo.getCount(); } orderCountByTimeVO.setTotalCount(totalCount); + orderCountByTimeVO.setTotalInsuranceAmount(totalInsuranceAmount); + + logger.info("查询订单数量结果:{}", JSONObject.toJSONString(orderCountByTimeVO)); return orderCountByTimeVO; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderCountByTimeVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderCountByTimeVO.java index 071af757e..3486090e3 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderCountByTimeVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderCountByTimeVO.java @@ -2,6 +2,7 @@ package com.jsowell.pile.vo.web; import lombok.Data; +import java.math.BigDecimal; import java.util.List; @@ -15,6 +16,8 @@ public class OrderCountByTimeVO { private List orderCountByTimeList; + private BigDecimal totalInsuranceAmount; + @Data public static class OrderCountByTimeListVO { @@ -31,6 +34,10 @@ public class OrderCountByTimeVO { private String startTime; private String endTime; private Integer count ; + + // 保险金额 + private BigDecimal insuranceAmount; + } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderListVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderListVO.java index a7eddbc3f..03732197a 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderListVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderListVO.java @@ -291,4 +291,9 @@ public class OrderListVO { * 实时充电度数 */ private String realTimeChargingDegree; + + /** + * 保险金额 + */ + private BigDecimal insuranceAmount; } diff --git a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml index dd5514275..534d495fd 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml @@ -1906,6 +1906,7 @@ t1.virtual_amount as virtualAmount, t1.discount_amount as discountAmount, t1.settle_amount as settleAmount, + t1.insurance_amount as insuranceAmount, ifnull(t1.actual_received_amount, '0') as actualReceivedAmount, t1.settlement_time as settlementTime, t1.start_soc as startSoc,