diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NeiMengGuController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NeiMengGuController.java index 7cb6e314b..8ea231fa3 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NeiMengGuController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NeiMengGuController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.response.RestApiResponse; import com.jsowell.pile.dto.QueryOperatorInfoDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.thirdparty.CommonParamsDTO; @@ -11,10 +12,7 @@ import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -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 org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.Map; @@ -153,4 +151,44 @@ public class NeiMengGuController extends ThirdPartyBaseController { } } + /** + * 推送充换电站用能统计信息 notificationOperationStatsInfo + * @return + */ + @GetMapping("/v1/notificationOperationStatsInfo/{stationId}") + public RestApiResponse notificationOperationStatsInfo(@PathVariable String stationId) { + logger.info("{}-推送充换电站用能统计信息 params:{}", platformName, stationId); + RestApiResponse response = null; + try { + // 执行逻辑 + String result = platformLogic.notificationOperationStatsInfo(stationId); + response = new RestApiResponse<>(result); + } catch (Exception e) { + logger.error("{}-推送充换电站用能统计信息", platformName, e); + response = new RestApiResponse<>(e); + } + logger.info("{}-推送充换电站用能统计信息 result:{}", platformName, response); + return response; + } + + /** + * 推送历史充电订单 notificationChargeOrderInfoHistory + * @return + */ + @GetMapping("/v1/notificationChargeOrderInfoHistory/{orderCode}") + public RestApiResponse notificationChargeOrderInfoHistory(@PathVariable String orderCode) { + logger.info("{}-推送历史充电订单 params:{}", platformName, orderCode); + RestApiResponse response = null; + try { + // 执行逻辑 + String result = platformLogic.notificationChargeOrderInfoHistory(orderCode); + response = new RestApiResponse<>(result); + } catch (Exception e) { + logger.error("{}-推送历史充电订单", platformName, e); + response = new RestApiResponse<>(e); + } + logger.info("{}-推送历史充电订单 result:{}", platformName, response); + return response; + } + } diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/MemberController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/MemberController.java index 3bfdee774..ffc45580c 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/MemberController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/MemberController.java @@ -55,6 +55,10 @@ public class MemberController extends BaseController { @Autowired private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private PileStationInfoService pileStationInfoService; + /** * 下发短信接口 business * http://localhost:8080/uniapp/member/sendSMS @@ -611,14 +615,15 @@ public class MemberController extends BaseController { /** * 查询用户常去站点(最近半年) */ - @GetMapping("/getUserFrequentedStationList") - public RestApiResponse queryUserFrequentedStation(HttpServletRequest request) { + @PostMapping("/getUserFrequentedStationList") + public RestApiResponse queryUserFrequentedStation(HttpServletRequest request, @RequestBody QueryStationDTO dto) { RestApiResponse response; try { String memberId = getMemberIdByAuthorization(request); + dto.setMemberId(memberId); //查询order_basic_info表,根据member_id,对应的station_id,,然后根据station_id查询pile_station_info表中的站点名称,最后统计每个站点的次数,查询当前时间前半年的记录 - List list = orderBasicInfoService.queryUserFrequentedStation(memberId); - response = new RestApiResponse<>(ImmutableMap.of("list", list)); + PageResponse pageResponse = pileStationInfoService.queryUserFrequentedStation(dto); + response = new RestApiResponse<>(pageResponse); } catch (BusinessException e) { logger.error("查询用户常去站点(最近半年) error", e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java index 9ffb11607..b2ff53216 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java @@ -398,4 +398,6 @@ public class PileStationInfoController extends BaseController { } return result; } + + // public AjaxResult checkStationAmap } diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/StationSplitConfigController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/StationSplitConfigController.java index ae16a1fc4..ba607f4a4 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/StationSplitConfigController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/StationSplitConfigController.java @@ -3,7 +3,9 @@ package com.jsowell.web.controller.pile; import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.core.domain.AjaxResult; import com.jsowell.common.core.page.TableDataInfo; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.response.RestApiResponse; import com.jsowell.pile.dto.SplitConfigDTO; import com.jsowell.pile.service.StationSplitConfigService; import com.jsowell.pile.vo.web.SplitConfigVO; @@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.List; +import java.util.Map; /** * 站点分成配置controller @@ -56,4 +59,26 @@ public class StationSplitConfigController extends BaseController { } return ajaxResult; } + + /** + * 根据汇付会员id查询配置分账的站点列表 + * /station/splitconfig/queryStationList + * @param adapayMemberId + * @return + */ + @PostMapping("/queryStationList") + public RestApiResponse>> queryStationList(String adapayMemberId) { + RestApiResponse response = null; + Map> result = null; + try { + result = stationSplitConfigService.queryStationList(adapayMemberId); + } catch (BusinessException e) { + logger.error("查询站点列表失败" , e); + response = new RestApiResponse<>(e.getCode() , e.getMessage()); + } catch (Exception e) { + logger.error("查询站点列表失败" , e); + response = new RestApiResponse<>(ReturnCodeEnum.CODE_FAILED); + } + return new RestApiResponse<>(result); + } } diff --git a/jsowell-admin/src/main/resources/application-pre.yml b/jsowell-admin/src/main/resources/application-pre.yml index 17982b4c6..abd63f073 100644 --- a/jsowell-admin/src/main/resources/application-pre.yml +++ b/jsowell-admin/src/main/resources/application-pre.yml @@ -8,17 +8,17 @@ spring: # redis 配置 redis: # 地址 - host: r-uf6k0uet7mihr5z78f.redis.rds.aliyuncs.com -# host: 106.14.94.149 +# host: r-uf6k0uet7mihr5z78f.redis.rds.aliyuncs.com + host: 106.14.94.149 # 端口,默认为6379 port: 6379 # 数据库索引 database: 0 # 账号 - username: jsowell +# username: jsowell # 密码 - password: js@160829 -# password: js160829 +# password: js@160829 + password: js160829 # 连接超时时间 timeout: 10s lettuce: @@ -38,12 +38,12 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://rm-uf6ra51u33dc3798l.mysql.rds.aliyuncs.com:3306/jsowell_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: jsowell - password: js@160829 -# url: jdbc:mysql://106.14.94.149:3306/jsowell_pre?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 -# username: jsowell_pre -# password: Js@160829 +# url: jdbc:mysql://rm-uf6ra51u33dc3798l.mysql.rds.aliyuncs.com:3306/jsowell_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: jsowell +# password: js@160829 + url: jdbc:mysql://106.14.94.149:3306/jsowell_pre?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: jsowell_pre + password: Js@160829 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index 1ba6534a7..a304c6a4c 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -18,7 +18,7 @@ public enum ThirdPlatformTypeEnum { HAI_NAN_1_PLATFORM("7", "海南一张网(监管平台)", "578725200"), HAI_NAN_2_PLATFORM("8", "海南一张网(充电平台)", "MAA9A0PP1"), HUA_WEI("9", "华为平台", "MA5GTQ528"), - NEI_MENG_GU_PLATFORM("10", "内蒙古平台", ""), + NEI_MENG_GU_PLATFORM("10", "内蒙古平台", "MAB03NTXZ"), QING_HAI_PLATFORM("11", "青海平台", "630000000"), DIAN_XING_PLATFORM("12", "宁波点行停车平台", ""), NING_XIA_PLATFORM("13", "宁夏平台", "MA01H3BQ9"), diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/OrderBasicInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/OrderBasicInfoMapper.java index 02755e366..ffe3dc643 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/OrderBasicInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/OrderBasicInfoMapper.java @@ -404,13 +404,5 @@ public interface OrderBasicInfoMapper { */ List selectThirdPartyOrderList(@Param("dto") QueryStartChargeDTO dto); - - /** - * 查询用户常用站点信息 - * @param memberId - * @param startTime - * @param endTime - * @return - */ - List queryUserFrequentedStation(@Param("memberId") String memberId ,@Param("startTime") String startTime ,@Param("endTime") String endTime); + LocalDateTime queryOrderCreateTimeByStationId(String id); } \ No newline at end of file diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileConnectorInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileConnectorInfoMapper.java index 0cbf9e8e4..5aea037a5 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileConnectorInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileConnectorInfoMapper.java @@ -135,4 +135,11 @@ public interface PileConnectorInfoMapper { * @return */ List batchSelectConnectorList(@Param("stationIds") List stationIds); + + /** + * 查询异常设备数量 + * @param stationId + * @return + */ + List queryAbnormalDeviceCount(String stationId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileStationInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileStationInfoMapper.java index 1356307e4..52bcc3997 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileStationInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileStationInfoMapper.java @@ -1,6 +1,7 @@ package com.jsowell.pile.mapper; import com.jsowell.pile.domain.PileStationInfo; +import com.jsowell.pile.domain.UserFrequentedStationInfo; import com.jsowell.pile.dto.QueryStationDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.dto.amap.GetStationInfoDTO; @@ -122,4 +123,13 @@ public interface PileStationInfoMapper { PileStationInfo queryInfoByDeptId(@Param("deptId") String deptId); List getStationInfosByMerchantIds(@Param("list") List merchantIds); + + /** + * 查询用户常用站点信息 + * @param memberId + * @param startTime + * @param endTime + * @return + */ + List queryUserFrequentedStation(@Param("memberId") String memberId ,@Param("startTime") String startTime ,@Param("endTime") String endTime); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/StationSplitConfigMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/StationSplitConfigMapper.java index adf38e062..d6f861fc0 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/StationSplitConfigMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/StationSplitConfigMapper.java @@ -1,6 +1,7 @@ package com.jsowell.pile.mapper; import com.jsowell.pile.domain.StationSplitConfig; +import com.jsowell.pile.vo.web.SplitConfigVO; import org.apache.ibatis.annotations.Param; import java.util.Date; @@ -26,4 +27,11 @@ public interface StationSplitConfigMapper { int deleteByMerchantIdAndStationId(@Param("merchantId") String merchantId, @Param("stationId") String stationId, @Param("updateBy") String updateBy, @Param("updateTime") Date updateTime); int deleteByStationId(@Param("stationId") String stationId, @Param("updateBy") String updateBy, @Param("updateTime") Date updateTime); + + /** + * 根据汇付会员id查询配置列表 + * @param adapayMemberId + * @return + */ + List queryStationList(String adapayMemberId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java index 39165625c..3bc9e3817 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java @@ -544,13 +544,6 @@ public interface OrderBasicInfoService{ void retryRefundOrderList(List orderCoderList); - /** - * 查询用户常用充电站点信息 - * @param memberId - * @return - */ - List queryUserFrequentedStation(String memberId); - /** * 通过订单编号列表查询订单信息 * @param orderCodeList 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 a7ed68530..4d48d9cb1 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 @@ -176,4 +176,11 @@ public interface PileConnectorInfoService { * @return */ public BusinessConnectorInfoVO getBusinessPileConnectorDetail(String pileConnectorCode); + + /** + * 查询异常设备数量 + * @param id + * @return + */ + int queryAbnormalDeviceCount(String id); } 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 5732c9213..a86adf2ad 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 @@ -2,6 +2,7 @@ package com.jsowell.pile.service; import com.jsowell.common.core.page.PageResponse; import com.jsowell.pile.domain.PileStationInfo; +import com.jsowell.pile.domain.UserFrequentedStationInfo; import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.amap.GetStationInfoDTO; import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; @@ -203,4 +204,11 @@ public interface PileStationInfoService { * @return */ StationBusinessAnalyzeInfoVO getStationConnectorUsedInfo(StationBusinessAnalyzeInfoDTO dto); + + /** + * 查询用户常用充电站点信息 + * @param dto + * @return + */ + PageResponse queryUserFrequentedStation(QueryStationDTO dto); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/StationSplitConfigService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/StationSplitConfigService.java index 40e5095e4..e9ac82fea 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/StationSplitConfigService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/StationSplitConfigService.java @@ -7,6 +7,7 @@ import com.jsowell.pile.vo.web.SplitConfigVO; import java.util.Date; import java.util.List; +import java.util.Map; /** * 站点分成配置service @@ -50,5 +51,10 @@ public interface StationSplitConfigService { */ List queryShareMembersByStationId(String stationId); - + /** + * 根据站点id查询站点分账配置信息 + * @param adapayMemberId + * @return + */ + Map> queryStationList(String adapayMemberId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index bb4a8254b..96a23b62d 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -4970,18 +4970,6 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { } - /** - * 查询用户常用站点信息 - * @param memberId - * @return - */ - @Override - public List queryUserFrequentedStation(String memberId) { - String endTime = DateUtils.getDate(); - String startTime = DateUtils.getHalfYearAgo(endTime); - return orderBasicInfoMapper.queryUserFrequentedStation(memberId, startTime, endTime); - } - @Override public List queryAfterSettleOrderDTOList(List orderCodeList) { return null; 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 bf8dd217b..66f06bdf1 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 @@ -1164,4 +1164,20 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { vo.setBusinessConnectorDetail(detailVO); return vo; } + + + /** + * 统计异常设备数量 + * @param stationId + * @return + */ + @Override + public int queryAbnormalDeviceCount(String stationId) { + List list = pileConnectorInfoMapper.queryAbnormalDeviceCount(stationId); + if (CollectionUtils.isEmpty(list)){ + return 0; + } + Set set = new HashSet<>(list); + return set.size(); + } } 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 086d332f9..d30104ad5 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,10 +16,7 @@ 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.pile.domain.PileBasicInfo; -import com.jsowell.pile.domain.PileStationInfo; -import com.jsowell.pile.domain.SettleOrderReport; -import com.jsowell.pile.domain.ThirdpartyParkingConfig; +import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.FastCreateStationDTO; import com.jsowell.pile.dto.QueryStationDTO; import com.jsowell.pile.dto.QueryStationInfoDTO; @@ -28,6 +25,7 @@ import com.jsowell.pile.dto.business.StationBusinessAnalyzeInfoDTO; import com.jsowell.pile.dto.business.StationStatisticsInfoDTO; import com.jsowell.pile.dto.lutongyunting.BindParkingPlatformDTO; import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO; +import com.jsowell.pile.mapper.OrderBasicInfoMapper; import com.jsowell.pile.mapper.PileStationInfoMapper; import com.jsowell.pile.service.*; import com.jsowell.pile.util.UserUtils; @@ -52,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.text.DecimalFormat; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.TimeUnit; @@ -103,6 +102,8 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { @Autowired private SettleOrderReportService settleOrderReportService; + @Autowired + private OrderBasicInfoMapper orderBasicInfoMapper; /** * 查询充电站信息 @@ -589,6 +590,18 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { stationVO.setVipServicePrice(currentTimePriceDetails.getVipServicePrice()); stationVO.setVipTotalPrice(currentTimePriceDetails.getVipTotalPrice()); } + + //根据站点id查询订单最后一次交易时间 + LocalDateTime lastChargeTime = orderBasicInfoMapper.queryOrderCreateTimeByStationId(pileStationVO.getId()); + if (lastChargeTime != null) { + String s = lastChargeTime.toString(); + String replace = s.replace("T" , " "); + stationVO.setLastChargeTime(replace); + } + + //根据站点id查询异常设备数量 + stationVO.setAbnormalDeviceCount(pileConnectorInfoService.queryAbnormalDeviceCount(pileStationVO.getId())); + stationVOList.add(stationVO); } @@ -1394,4 +1407,24 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { vo.setBusinessOrderDetailInfoVOList(list); return vo; } + + /** + * 查询用户常用站点信息 + * @param dto + * @return + */ + @Override + public PageResponse queryUserFrequentedStation(QueryStationDTO dto) { + String endTime = DateUtils.getDate(); + String startTime = DateUtils.getHalfYearAgo(endTime); + List frequentedStationInfos = pileStationInfoMapper.queryUserFrequentedStation(dto.getMemberId(), startTime, endTime); + // 筛选出站点idList + List stationIdList = frequentedStationInfos.stream() + .map(UserFrequentedStationInfo::getStationId) + .collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(stationIdList)) { + dto.setStationIds(stationIdList); + } + return uniAppQueryStationInfoListV2(dto); + } } \ No newline at end of file diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/StationSplitConfigServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/StationSplitConfigServiceImpl.java index 98531dce5..711aa7a5e 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/StationSplitConfigServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/StationSplitConfigServiceImpl.java @@ -27,8 +27,11 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; @Slf4j @Service @@ -286,4 +289,29 @@ public class StationSplitConfigServiceImpl implements StationSplitConfigService{ } return true; } + + /** + * 根据汇付会员id查询配置分账的站点列表 + * + * @param adapayMemberId + * @return + */ + @Override + public Map> queryStationList(String adapayMemberId) { + List stationList = stationSplitConfigMapper.queryStationList(adapayMemberId); + if (stationList == null || stationList.isEmpty()){ + throw new BusinessException("", "未查询到该汇付会员的分账配置信息"); + } + //按照站点id进行去重,再将id按照降序排序,因为站点id为String类型,所以需要先转换为int类型 + stationList = stationList.stream() + .filter(vo -> vo.getStationId() != null && vo.getStationId().matches("^\\d+")) + .distinct() + .sorted((o1, o2) -> Integer.parseInt(o1.getStationId()) - Integer.parseInt(o2.getStationId())) + .collect(Collectors.toList()); + + Map> stationMap = new HashMap<>(); + stationMap.put("stationList", stationList); + return stationMap; + } + } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/StationInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/StationInfoVO.java index eace4ffa5..a110a34f4 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/StationInfoVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/StationInfoVO.java @@ -133,6 +133,16 @@ public class StationInfoVO { */ private boolean collectedFlag; + /** + * 当前站点最近充电的一次时间 + */ + private String lastChargeTime; + + /** + * 异常设备数量 + */ + private int abnormalDeviceCount; + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/SplitConfigVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/SplitConfigVO.java index 3336117bd..211db6203 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/SplitConfigVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/SplitConfigVO.java @@ -39,4 +39,15 @@ public class SplitConfigVO { */ private String feeFlag; + /** + * 站点id + */ + private String stationId; + + /** + * 站点名称 + */ + private String stationName; + + } diff --git a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml index bb7f61921..97174ca91 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml @@ -3119,22 +3119,18 @@ - SELECT - t1.station_id AS stationId, - t2.station_name AS stationName, - COUNT(t1.id) AS chargeNum + create_time FROM - order_basic_info t1 - JOIN - pile_station_info t2 ON t1.station_id = t2.id + order_basic_info WHERE - t1.member_id = #{memberId} - AND t1.create_time BETWEEN #{startTime} AND #{endTime} - GROUP BY - t1.station_id, t2.station_name + del_flag = '0' + and + station_id = #{stationId} ORDER BY - chargeNum DESC; + create_time DESC + LIMIT 1; \ No newline at end of file diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileConnectorInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileConnectorInfoMapper.xml index 4e5cf5e33..9dc1f336f 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileConnectorInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileConnectorInfoMapper.xml @@ -305,4 +305,18 @@ #{stationId, jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml index 27172f9d2..7f75b48a9 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml @@ -706,4 +706,22 @@ + + \ No newline at end of file diff --git a/jsowell-pile/src/main/resources/mapper/pile/StationSplitConfigMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/StationSplitConfigMapper.xml index a956ac38d..88b6be720 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/StationSplitConfigMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/StationSplitConfigMapper.xml @@ -32,6 +32,15 @@ order by fee_flag + + insert into station_split_config diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java index 262f531f6..2c97c5e80 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java @@ -131,10 +131,12 @@ public class NotificationService { logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 订单编号:{}, 设备充电中状态变化推送error:{}", secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, orderCode, e.getMessage()); } - try { - platformService.notificationEquipChargeStatus(orderCode); - }catch (Exception e){ - logger.error("notification_equip_charge_status error", e); + finally { + try { + platformService.notificationEquipChargeStatus(orderCode); + }catch (Exception e){ + logger.error("notification_equip_charge_status error", e); + } } } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData.java index 6b4ef6778..06efcfaec 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData.java @@ -24,6 +24,56 @@ public class ChargeAlgorithmData { */ private String orderCode; + /** + * 站点详细地址 + */ + private String siteAddress; + + /** + * 站点编号 + */ + private String siteCode; + + /** + * 桩编号 + */ + private String pileCode; + + /** + * 枪编号 + */ + private String gunNo; + + /** + * 车主年龄段 + */ + private String age; + + /** + * 车主性别 + */ + private String gender; + + /** + * 用车场景 + */ + private String scene; + + /** + * 车辆使用年限 + */ + private String serviceLife; + + /** + * 车辆累计里程 + */ + private String odometer; + + /** + * 站点名称 + */ + private String siteName; + /** * 初始SOC */ diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java index 3e454c554..b857bd1d0 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupEquipChargeStatusInfo.java @@ -187,6 +187,18 @@ public class SupEquipChargeStatusInfo { @JSONField(name = "ServiceMoney") private String serviceMoney; + /** + * 电池编码 + */ + @JSONField(name = "BatteryPackID") + private String batteryPackId; + + /** + * 当前电表读数 + */ + @JSONField(name = "CurrentMeter") + private String currentMeter; + /** * 时段数 * 参数范围:0~ 32 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatsInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatsInfo.java index 8ab818b72..993f1edb9 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatsInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/SupStationStatsInfo.java @@ -56,6 +56,30 @@ public class SupStationStatsInfo { @JSONField(name = "StationElectricity") private BigDecimal stationElectricity; + /** + * 累计充电量 + */ + @JSONField(name = "DailyChargeEnergy") + private BigDecimal dailyChargeEnergy; + + /** + * 累计其他电量 + */ + @JSONField(name = "DailyOtherEnergy") + private BigDecimal dailyOtherEnergy; + + /** + * 累计换电次数 + */ + @JSONField(name = "DailySwapNum") + private Integer dailySwapNum; + + /** + * 累计充电次数 + */ + @JSONField(name = "DailyChargeNum") + private Integer dailyChargeNum; + /** * 充换电站累计充电量 */ diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java index 8b1551d17..09517a058 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java @@ -7,6 +7,7 @@ import com.google.common.collect.Maps; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.redis.RedisCache; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.StringUtils; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java index 46d281730..59fe2f367 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java @@ -12,8 +12,10 @@ import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.OrderSplitRecord; import com.jsowell.pile.service.OrderBasicInfoService; import com.jsowell.pile.service.PileBasicInfoService; +import com.jsowell.pile.service.PileStationInfoService; import com.jsowell.pile.thirdparty.ParameterConfigData; import com.jsowell.pile.vo.uniapp.customer.OrderVO; +import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,10 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -43,6 +42,9 @@ public class ChargeAlgorithmService { @Autowired private PileBasicInfoService pileBasicInfoService; + @Autowired + private PileStationInfoService pileStationInfoService; + @Autowired private RedisCache redisCache; @@ -58,6 +60,9 @@ public class ChargeAlgorithmService { if (orderVO == null) { return "订单信息为空"; } + // 查询站点信息 + PileStationVO stationVO = pileStationInfoService.getStationInfo(orderVO.getStationId()); + // 计算充电时长 long chargingTime = DateUtils.intervalTime(orderVO.getStartTime(), orderVO.getEndTime()); String transactionCode = orderVO.getTransactionCode(); @@ -125,16 +130,31 @@ public class ChargeAlgorithmService { // .gunTemp("0") // 充电枪温度 .doorStatus(Constants.zero) // 舱门状态 + .siteAddress(stationVO.getAddress()) + .siteCode(stationVO.getId()) + .pileCode(orderVO.getPileSn()) + .gunNo(orderVO.getPileConnectorCode()) + .age("0") + .gender("0") + .scene("0") + .serviceLife("0") + .odometer("0") + .siteName(stationVO.getStationName()) + .build(); List chargingDetailInfos = transformData(transactionCode, chargerOutputInfoList, parameterConfigData, transactionRecordsData); + chargingDetailInfos.stream() + .filter(info -> info.getCurrentSoc() > 100) // 只处理 currentSoc > 100 的元素 + .forEach(info -> info.setCurrentSoc(100)); + Collections.reverse(chargingDetailInfos); data.setChargingDetailInfo(chargingDetailInfos); JSONObject jsonObject = new JSONObject(); - jsonObject.put("dataJason", data); + jsonObject.put("dataJson", data); log.info("发送请求前封装数据 data:{}", JSON.toJSONString(jsonObject)); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java index 5ca48cccd..a8215d158 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NeiMengGuPlatformServiceImpl.java @@ -1,21 +1,27 @@ package com.jsowell.thirdparty.platform.service.impl; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; +import com.jsowell.common.enums.ykc.OrderStatusEnum; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.*; +import com.jsowell.common.util.bean.BeanUtils; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.domain.OrderDetail; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; @@ -28,6 +34,7 @@ import com.jsowell.pile.service.*; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.pile.util.MerchantUtils; +import com.jsowell.pile.vo.SupStationStatsVO; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.MerchantInfoVO; @@ -41,15 +48,13 @@ import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; +import com.jsowell.thirdparty.lianlian.vo.LianLianResultVO; import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.platform.domain.*; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; -import com.jsowell.thirdparty.platform.util.Cryptos; -import com.jsowell.thirdparty.platform.util.Encodes; -import com.jsowell.thirdparty.platform.util.HttpRequestUtil; -import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; +import com.jsowell.thirdparty.platform.util.*; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import com.yi.business.geo.GeoCodeInfo; import com.yi.business.geo.TermRelationTreeCoordinate; @@ -61,6 +66,8 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -196,7 +203,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { map.put("ItemSize", pageInfo.getTotal()); map.put("OperatorInfos", operatorInfos); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), + thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); return resultMap; } @@ -299,7 +307,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { map.put("PageCount", pageInfo.getPages()); map.put("ItemSize", pageInfo.getTotal()); map.put("StationInfos", resultList); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), + thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); return resultMap; } @@ -405,7 +414,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // map.put("Total", total); map.put("StationStatusInfos", collect); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), + thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); return resultMap; } @@ -456,7 +466,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 结果集 Map map = Maps.newHashMap(); map.put("StationStatusInfos", stationStatusInfos); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(), + thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); return resultMap; } @@ -479,7 +490,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); - String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); @@ -497,7 +508,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { String jsonString = JSON.toJSONString(json); // 获取令牌 String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -532,7 +543,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { .build(); // 调用联联平台接口 - String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = secretInfoVO.getTheirOperatorSecret(); String signSecret = secretInfoVO.getTheirSigSecret(); String dataSecret = secretInfoVO.getTheirDataSecret(); @@ -545,10 +556,75 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { String jsonString = JSON.toJSONString(info); // 获取令牌 String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, secretInfoVO.getPlatformType()); return result; } + @Override + public String getToken(String urlAddress, String operatorId, String operatorSecret, String dataSecretIv, String signSecret, String dataSecret) { + String token = ""; + // 先查询缓存有没有token + String tokenKey = CacheConstants.THIRD_PARTY_TOKEN_BY_OPERATOR_SECRET + operatorSecret; + RedisCache redisCache = BeanUtils.getBean(RedisCache.class); + String cacheToken = redisCache.getCacheObject(tokenKey); + if (StringUtils.isNotBlank(cacheToken)) { + token = cacheToken; + return token; + } + + try { + // 请求地址 + String requestUrl = urlAddress + "query_token"; + + // 请求data + Map data = new HashMap<>(); + data.put("PlatformID", operatorId); + data.put("OperatorSecret", operatorSecret); + data.put("DataSecretIV", dataSecretIv); + String dataJson = JSONUtil.toJsonStr(data); + + // 加密 + byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes(StandardCharsets.UTF_8), + dataSecret.getBytes(), dataSecretIv.getBytes()); + String strData = Encodes.encodeBase64(encryptText); + + Map request = new LinkedHashMap<>(); + request.put("PlatformID", operatorId); + request.put("Data", strData); + request.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date())); + request.put("Seq", "0001"); + + // 生成签名 + String sig = GBSignUtils.sign(request, signSecret); + request.put("Sig", sig); + + String tokenRequest = JSONUtil.toJsonStr(request); + + String response = HttpUtil.post(requestUrl, tokenRequest); + LianLianResultVO result = JSON.parseObject(response, LianLianResultVO.class); +// logger.info("获取令牌 result:{}", result); + + if (result.getRet() == 0) { + // 解密data + byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) result.getData()), + dataSecret.getBytes(), dataSecretIv.getBytes()); + String dataStr = new String(plainText, StandardCharsets.UTF_8); + Map resultMap = (Map) JSON.parse(dataStr); + token = String.valueOf(resultMap.get("AccessToken")); + if (resultMap.get("TokenAvailableTime") != null) { + int tokenAvailableTime = Integer.parseInt(String.valueOf(resultMap.get("TokenAvailableTime"))); + // 将token存入缓存 + redisCache.setCacheObject(tokenKey, token, tokenAvailableTime, TimeUnit.SECONDS); + } + // logger.info("token: {}", token); + } + // logger.info("获取令牌 result:{}, token: {}", result, token); + } catch (Exception e) { + return token; + } + return token; + } + /** * 充电订单推送 notification_charge_order_info * @@ -566,7 +642,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); - String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); @@ -609,7 +685,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { JSONObject json = new JSONObject(); json.put("ChargeOrderInfo", orderInfo); String jsonString = JSON.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -627,7 +703,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // return null; // } - String operatorId = secretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = secretInfoVO.getTheirOperatorSecret(); String signSecret = secretInfoVO.getTheirSigSecret(); String dataSecret = secretInfoVO.getTheirDataSecret(); @@ -641,7 +717,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { } // 推送地址 - String url = urlAddress + "notification_orderInfo"; + String url = urlAddress + "supervise_notification_charge_order_info"; // 拼装成内蒙古平台所需格式对象 ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); @@ -667,10 +743,10 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { return null; } // 调用联联平台接口 - JSONObject json = new JSONObject(); - json.put("ChargeOrderInfo", orderInfo); - String jsonString = JSON.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + // JSONObject json = new JSONObject(); + // json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(orderInfo); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -685,39 +761,72 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { public String notificationEquipChargeStatus(String orderCode) { // 根据订单号查询订单信息 OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode()); + // 根据站点id查询运营商id + PileStationVO stationVO = pileStationInfoService.getStationInfo(orderInfo.getStationId()); + + // 查询枪口实时状态 + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); + RealTimeMonitorData realTimeMonitorData; + if (CollectionUtils.isEmpty(chargingRealTimeData)) { + realTimeMonitorData = RealTimeMonitorData.builder() + .chargingDegree(Constants.ZERO) + .connectorStatus("3") + .build(); + chargingRealTimeData.add(realTimeMonitorData); + } else { + realTimeMonitorData = chargingRealTimeData.get(0); + } + String orderStatus = orderInfo.getOrderStatus(); + if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) { + // 充电中 + orderStatus = "2"; + } else if (StringUtils.equals(OrderStatusEnum.ORDER_COMPLETE.getValue(), orderStatus)) { + // 充电完成 + orderStatus = "4"; + } + BigDecimal current = realTimeMonitorData.getOutputCurrent() == null ? BigDecimal.ZERO : new BigDecimal(realTimeMonitorData.getOutputCurrent()); + BigDecimal voltage = realTimeMonitorData.getOutputVoltage() == null ? BigDecimal.ZERO : new BigDecimal(realTimeMonitorData.getOutputVoltage()); + String soc = realTimeMonitorData.getSOC() == null ? Constants.ZERO : realTimeMonitorData.getSOC(); // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); - String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); - // 调用 查询充电状态方法 - QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO(); - dto.setStartChargeSeq(orderCode); - dto.setOperatorID(thirdPartySecretInfoVO.getTheirOperatorId()); - Map map = queryEquipChargeStatus(dto); - if (map == null) { - return null; - } - String data = map.get("Data"); - // 解密data (此处解密需用 thirdparty_platform_config 的密钥配置) - byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data), - thirdPartySecretInfoVO.getOurDataSecret().getBytes(), thirdPartySecretInfoVO.getOurDataSecretIv().getBytes()); - String dataStr = new String(plainText, StandardCharsets.UTF_8); - // 转成对应的对象 - QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class); + SupEquipChargeStatusInfo equipChargeStatusInfo = SupEquipChargeStatusInfo.builder() + .operatorID(operatorId) + .equipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(stationVO.getOrganizationCode())) + .stationID(orderInfo.getStationId()) + .equipmentID(orderInfo.getPileSn()) + .orderNo(orderInfo.getOrderCode()) + .orderStatus(Integer.parseInt(orderStatus)) + .connectorID(orderInfo.getPileConnectorCode()) + .equipmentClassification(1) // 车辆充电设备接口 + .pushTimeStamp(DateUtils.dateTimeNow()) + .connectorStatus(Integer.parseInt(realTimeMonitorData.getConnectorStatus())) + .currentA(current) + .voltageA(voltage) + .soc(new BigDecimal(soc)) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(DateUtils.getDateTime()) + .totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())) + .batteryPackId("") + .currentMeter("") - String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue(); + .build(); + + String url = urlAddress + "supervise_notification_equip_charge_status"; // 调用联联平台接口 - String jsonString = JSON.toJSONString(vo); + String jsonString = JSON.toJSONString(equipChargeStatusInfo); // 获取令牌 String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -729,7 +838,65 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { */ @Override public String notificationOperationStatsInfo(String stationId) { - return ThirdPartyPlatformService.super.notificationOperationStatsInfo(stationId); + List resultList = new ArrayList<>(); + // 根据站点id查询订单记录 (新建Service方法) + List orderVOS = orderBasicInfoService.queryOrderListByStationId(stationId); + // 根据订单信息汇总出站点充电数据 + BigDecimal stationTotalElectricity = BigDecimal.ZERO; // 充电站累计用电量 + int stationChargeTime = Constants.zero; // 充电站累计充电次数 + for (SupStationStatsVO orderVO : orderVOS) { + // 充电站累计用电量 + BigDecimal totalPower = orderVO.getTotalPower(); + if (totalPower == null || orderVO.getChargingTime() == null) { + continue; + } + stationTotalElectricity = stationTotalElectricity.add(totalPower); + // 充电站累计充电时长(分钟) + stationChargeTime += orderVO.getChargingTime(); + } + + // 创建对象 + String startTime = DateUtils.getYesterdayStr() + " 00:00:00"; + String endTime = DateUtils.getYesterdayStr() + " 23:59:59"; + SupStationStatsInfo supStationStatsInfo = SupStationStatsInfo.builder() + .stationId(stationId) + .operatorId(Constants.OPERATORID_JIANG_SU) + .equipmentOwnerId(ThirdPartyPlatformUtils.extractEquipmentOwnerID(orderVOS.get(0).getOrganizationCode())) + // .stationClassification(1) + .startTime(startTime) + .endTime(endTime) + .stationElectricity(stationTotalElectricity) + .dailyChargeEnergy(stationTotalElectricity) + .dailyOtherEnergy(new BigDecimal("0")) + .dailySwapNum(0) + .dailyChargeNum(orderVOS.size()) + .stationTotalChargeTime(stationChargeTime) + .stationTotalSwapTime(0) + .stationTotalWarningNum(0) + .build(); + resultList.add(supStationStatsInfo); + + JSONObject json = new JSONObject(); + json.put("StationStatsInfos", resultList); + String jsonString = JSON.toJSONString(json); + // 发送推送请求 + ThirdPartySecretInfoVO ningXiaSecretInfo = getNeiMengGuPlatformSecretInfo(); + + String operatorId = Constants.OPERATORID_LIANLIAN; + String operatorSecret = ningXiaSecretInfo.getTheirOperatorSecret(); + String signSecret = ningXiaSecretInfo.getTheirSigSecret(); + String dataSecret = ningXiaSecretInfo.getTheirDataSecret(); + String dataSecretIv = ningXiaSecretInfo.getTheirDataSecretIv(); + String urlAddress = ningXiaSecretInfo.getTheirUrlPrefix(); + String url = urlAddress + "supervise_notification_operation_stats_info"; + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用平台接口 + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); + return result; } /** @@ -747,7 +914,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNeiMengGuPlatformSecretInfo(); - String operatorId = thirdPartySecretInfoVO.getTheirOperatorId(); + String operatorId = Constants.OPERATORID_LIANLIAN; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); @@ -780,10 +947,10 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { return null; } // 调用联联平台接口 - JSONObject json = new JSONObject(); - json.put("ChargeOrderInfo", orderInfo); - String jsonString = JSON.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + // JSONObject json = new JSONObject(); + // json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(orderInfo); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret, thirdPlatformType); return result; } @@ -885,7 +1052,7 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService { if (thirdPartySecretInfoVO == null) { throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); } - thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_LIANLIAN); return thirdPartySecretInfoVO; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/HttpRequestUtil.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/HttpRequestUtil.java index 8c03f2f5e..f84621db6 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/HttpRequestUtil.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/HttpRequestUtil.java @@ -135,7 +135,12 @@ public class HttpRequestUtil { String encryptData = Encodes.encodeBase64(encryptText); Map params = Maps.newLinkedHashMap(); - params.put("OperatorID", operatorId); + if (ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode().equals(thirdPlatformType)) { + // 内蒙古平台 + params.put("PlatformID", operatorId); + }else { + params.put("OperatorID", operatorId); + } params.put("Data", encryptData); params.put("TimeStamp", DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date())); params.put("Seq", "001"); @@ -145,6 +150,7 @@ public class HttpRequestUtil { params.put("Portname", "wcc-pro"); } + String sign = GBSignUtils.sign(params, sigSecret); params.put("Sig", sign);