@@ -1,5 +1,6 @@
package com.jsowell.pile.service.impl ;
import cn.hutool.core.util.CoordinateUtil ;
import com.github.pagehelper.PageHelper ;
import com.github.pagehelper.PageInfo ;
import com.google.common.collect.Lists ;
@@ -13,7 +14,10 @@ import com.jsowell.common.core.redis.RedisCache;
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.DateUtils ;
import com.jsowell.common.util.DistanceUtils ;
import com.jsowell.common.util.SecurityUtils ;
import com.jsowell.common.util.StringUtils ;
import com.jsowell.common.util.ip.AddressUtils ;
import com.jsowell.pile.domain.PileBasicInfo ;
import com.jsowell.pile.domain.PileStationInfo ;
@@ -26,18 +30,16 @@ import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
import com.jsowell.pile.mapper.PileStationInfoMapper ;
import com.jsowell.pile.service.* ;
import com.jsowell.pile.util.UserUtils ;
import com.jsowell.pile.vo.uniapp.business.BusinessOrderDetailInfoVO ;
import com.jsowell.pile.vo.uniapp.business.StationBusinessAnalyzeInfoVO ;
import com.jsowell.pile.vo.base.* ;
import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO ;
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.customer.CurrentTimePriceDetails ;
import com.jsowell.pile.vo.web.PileStationVO ;
import com.jsowell.system.service.SysDeptService ;
import com.jsowell.system.service.SysUserService ;
import com.yi.business.geo.GeoCodeInfo ;
import com.yi.business.geo.TermRelationTreeCoordinate ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.collections4.CollectionUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
@@ -119,6 +121,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 查询站点基本资料
* 加缓存
*
* @param stationId
* @return
*/
@@ -205,6 +208,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 通过充电桩枪口编号查询充电站信息
*
* @param pileConnectorCode 充电桩枪口编号
* @return 充电站信息
*/
@@ -219,6 +223,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 通过充电桩sn查询充电站信息
*
* @param pileSn 充电桩sn
* @return 充电站信息
*/
@@ -317,6 +322,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 快速建站
*
* @param dto
* @return
*/
@@ -391,6 +397,17 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
}
}
// 2024年8月16日14点15分 天地图坐标转高德坐标
if ( StringUtils . isNotBlank ( pileStationInfo . getStationLng ( ) ) & & StringUtils . isNotBlank ( pileStationInfo . getStationLat ( ) ) ) {
// 获取经纬度
CoordinateUtil . Coordinate coordinate = CoordinateUtil . wgs84ToGcj02 ( Double . parseDouble ( pileStationInfo . getStationLng ( ) ) , Double . parseDouble ( pileStationInfo . getStationLat ( ) ) ) ;
if ( coordinate ! = null ) {
pileStationInfo . setStationLng ( String . valueOf ( coordinate . getLng ( ) ) ) ;
pileStationInfo . setStationLat ( String . valueOf ( coordinate . getLat ( ) ) ) ;
}
}
pileStationInfo . setUpdateBy ( SecurityUtils . getUsername ( ) ) ;
pileStationInfo . setUpdateTime ( DateUtils . getNowDate ( ) ) ;
int i = pileStationInfoMapper . updatePileStationInfo ( pileStationInfo ) ;
@@ -462,6 +479,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 充电站列表信息
*
* @param dto 前台参数
* @return 充电站对象集合
*/
@@ -505,13 +523,13 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
for ( PileStationVO pileStationVO : pageInfo . getList ( ) ) {
stationVO = new StationInfoVO ( ) ;
if ( StringUtils . isNotEmpty ( stationLng ) & & StringUtils . isNotEmpty ( stationLat ) ) {
try {
try {
// 计算当前经纬度和站点之间的距离
distance = DistanceUtils . getDistance ( Double . parseDouble ( stationLng ) , Double . parseDouble ( stationLat ) ,
Double . parseDouble ( pileStationVO . getStationLng ( ) ) , Double . parseDouble ( pileStationVO . getStationLat ( ) ) ) ;
// 保留两位小数
stationVO . setDistance ( String . format ( " %.2f " , distance ) ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
stationVO . setDistance ( " 0.00 " ) ;
}
@@ -581,6 +599,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 根据站点id查询运营商配置的汇付会员id
*
* @param stationId
* @return
*/
@@ -596,6 +615,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 通过站点部门id查询站点id
*
* @param deptId
* @return
*/
@@ -606,6 +626,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 绑定停车系统平台
*
* @param dto
*/
@Override
@@ -626,6 +647,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 查询充电站下拉列表
*
* @param dto
* @return
*/
@@ -644,6 +666,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 宁夏交投查询充电站信息
*
* @param dto
* @return
*/
@@ -661,12 +684,13 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
}
@Override
public List < PileStationInfo > getStationInfosByMerchantIds ( List < String > merchantIds ) {
public List < PileStationInfo > getStationInfosByMerchantIds ( List < String > merchantIds ) {
return pileStationInfoMapper . getStationInfosByMerchantIds ( merchantIds ) ;
}
/**
* 获取站点统计信息
*
* @param dto
*/
@Override
@@ -681,7 +705,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
merchantIds = merchantInfoVOList . stream ( )
. map ( MerchantInfoVO : : getMerchantId )
. collect ( Collectors . toList ( ) ) ;
} else {
} else {
merchantIds . add ( merchantId ) ;
}
if ( CollectionUtils . isEmpty ( stationIds ) ) {
@@ -715,7 +739,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
} ) ) ;
for ( Map . Entry < String , SettleOrderReport > entry : collect . entrySet ( ) ) {
for ( Map . Entry < String , SettleOrderReport > entry : collect . entrySet ( ) ) {
String stationId = entry . getKey ( ) ;
SettleOrderReport report = entry . getValue ( ) ;
@@ -734,16 +758,16 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . FREE . getValue ( ) , connectorStatus ) ) {
// 空闲
freeConnectorNum + = 1 ;
} else if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . OCCUPIED_NOT_CHARGED . getValue ( ) , connectorStatus ) ) {
} else if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . OCCUPIED_NOT_CHARGED . getValue ( ) , connectorStatus ) ) {
// 占用(未充电)
occupiedConnectorNum + = 1 ;
} else if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . OCCUPIED_CHARGING . getValue ( ) , connectorStatus ) ) {
} else if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . OCCUPIED_CHARGING . getValue ( ) , connectorStatus ) ) {
// 充电中
chargingConnectorNum + = 1 ;
} else if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . OFF_NETWORK . getValue ( ) , connectorStatus ) ) {
} else if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . OFF_NETWORK . getValue ( ) , connectorStatus ) ) {
// 离线
offlineConnectorNum + = 1 ;
} else if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . FAULT . getValue ( ) , connectorStatus ) ) {
} else if ( StringUtils . equals ( PileConnectorDataBaseStatusEnum . FAULT . getValue ( ) , connectorStatus ) ) {
// 故障
faultConnectorNum + = 1 ;
}
@@ -776,6 +800,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 获取站点运营分析信息( 7天、30天)
*
* @param dto
*/
@Override
@@ -811,7 +836,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
if ( StringUtils . equals ( Constants . ONE , type ) ) {
// 7天
date = DateUtils . addDays ( new Date ( ) , - 7 ) ;
} else if ( StringUtils . equals ( Constants . TWO , type ) ) {
} else if ( StringUtils . equals ( Constants . TWO , type ) ) {
// 30天
date = DateUtils . addDays ( new Date ( ) , - 30 ) ;
}
@@ -907,7 +932,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
vo . setOrderAmountGrowthRate ( " - " ) ;
vo . setServiceAmountGrowthRate ( " - " ) ;
// vo.setBusinessOrderDetailInfoVOList();
} else {
} else {
// 充电量增长率
todayUsedElectricity = orderDetailToday . getTotalUsedElectricity ( ) ;
yesterdayUsedElectricity = orderDetailYesterday . getTotalUsedElectricity ( ) ;
@@ -918,7 +943,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
todayServiceAmount = orderDetailToday . getTotalServiceAmount ( ) ;
yesterdayServiceAmount = orderDetailYesterday . getTotalServiceAmount ( ) ;
}
} else {
} else {
// 如果指定日期为空,则默认最后一天(当天)与前一天做对比
BusinessOrderDetailInfoVO orderDetailToday = businessOrderDetailInfoVOS . get ( businessOrderDetailInfoVOS . size ( ) - 1 ) ;
BusinessOrderDetailInfoVO orderDetailYesterday = businessOrderDetailInfoVOS . get ( businessOrderDetailInfoVOS . size ( ) - 2 ) ;
@@ -934,19 +959,19 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
}
if ( yesterdayUsedElectricity . compareTo ( BigDecimal . ZERO ) = = 0 ) {
usedElectricityRiseRate = " 0% " ;
} else {
} else {
BigDecimal divideUsedElectricity = todayUsedElectricity . subtract ( yesterdayUsedElectricity ) . divide ( yesterdayUsedElectricity , 2 , BigDecimal . ROUND_HALF_UP ) ;
usedElectricityRiseRate = divideUsedElectricity . multiply ( new BigDecimal ( " 100 " ) ) + " % " ;
}
if ( yesterdaySettleAmount . compareTo ( BigDecimal . ZERO ) = = 0 ) {
orderAmountRiseRate = " 0% " ;
} else {
} else {
BigDecimal divideSettleAmount = todaySettleAmount . subtract ( yesterdaySettleAmount ) . divide ( yesterdaySettleAmount , 2 , BigDecimal . ROUND_HALF_UP ) ;
orderAmountRiseRate = divideSettleAmount . multiply ( new BigDecimal ( " 100 " ) ) + " % " ;
}
if ( yesterdayServiceAmount . compareTo ( BigDecimal . ZERO ) = = 0 ) {
serviceAmountRiseRate = " 0% " ;
} else {
} else {
BigDecimal divideServiceAmount = todayServiceAmount . subtract ( yesterdayServiceAmount ) . divide ( yesterdayServiceAmount , 2 , BigDecimal . ROUND_HALF_UP ) ;
serviceAmountRiseRate = divideServiceAmount . multiply ( new BigDecimal ( " 100 " ) ) + " % " ;
}
@@ -960,6 +985,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 获取站点运营分析信息( 12个月)
*
* @param dto
*/
@Override
@@ -999,11 +1025,11 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
SettleOrderReport nowReportInfo = new SettleOrderReport ( ) ;
SettleOrderReport lastMonthReportInfo = new SettleOrderReport ( ) ;
if ( dateTime = = null ) {
if ( dateTime = = null ) {
// 为空默认对比最后一个月和前一个月的数据
nowReportInfo = settleOrderReports . get ( settleOrderReports . size ( ) - 1 ) ;
lastMonthReportInfo = settleOrderReports . get ( settleOrderReports . size ( ) - 2 ) ;
} else {
} else {
// 对比目标日期和目标日期前一个月数据
nowReportInfo = map . get ( dateTime ) ;
Date lastMonth = DateUtils . addMonths ( DateUtils . parseDate ( dateTime ) , - 1 ) ;
@@ -1048,6 +1074,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 查询订单数量趋势信息
*
* @param dto
* @return
*/
@@ -1067,7 +1094,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
// 30天
startTime = DateUtils . parseDateToStr ( DateUtils . YYYY_MM_DD , DateUtils . addDays ( new Date ( ) , - 30 ) ) ;
endTime = DateUtils . dateTimeNow ( DateUtils . YYYY_MM_DD ) ;
} else if ( StringUtils . equals ( Constants . THREE , type ) ) {
} else if ( StringUtils . equals ( Constants . THREE , type ) ) {
// 一年
startTime = DateUtils . getFirstDayOfLastYearMonth ( ) ;
endTime = DateUtils . getLastDayOfCurrentMonth ( ) ;
@@ -1088,7 +1115,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
a . setChargeNum ( String . valueOf ( new BigDecimal ( a . getChargeNum ( ) ) . add ( new BigDecimal ( b . getChargeNum ( ) ) ) ) ) ;
return a ;
} ) ) ;
} else {
} else {
collect = settleOrderReports . stream ( )
. peek ( report - > {
LocalDate date = LocalDate . parse ( report . getTradeDate ( ) , DateTimeFormatter . ofPattern ( " yyyy-MM-dd " ) ) ;
@@ -1118,7 +1145,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
StringUtils . equals ( Constants . TWO , type ) ) {
// 7天
format = DateUtils . YYYY_MM_DD ;
} else {
} else {
format = DateUtils . YYYY_MM ;
}
String yesterday = DateUtils . parseDateToStr ( format , DateUtils . addDays ( DateUtils . parseDate ( dateTime ) , - 1 ) ) ;
@@ -1132,7 +1159,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
if ( yesterdayOrderNum . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
BigDecimal orderNumRate = todayOrderNum . subtract ( yesterdayOrderNum ) . divide ( yesterdayOrderNum , 2 , BigDecimal . ROUND_HALF_UP ) ;
orderNumRateGrowthRate = orderNumRate . multiply ( new BigDecimal ( " 100 " ) ) + " % " ;
} else {
} else {
orderNumRateGrowthRate = todayOrderNum . multiply ( new BigDecimal ( " 100 " ) ) + " % " ;
}
vo . setOrderAmountGrowthRate ( orderNumRateGrowthRate ) ;
@@ -1143,6 +1170,7 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
/**
* 查询站点枪利用率趋势信息
*
* @param dto
* @return
*/