2023-03-04 16:29:55 +08:00
|
|
|
|
package com.jsowell.quartz.task;
|
|
|
|
|
|
|
2025-04-16 15:50:26 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2025-02-13 11:49:52 +08:00
|
|
|
|
import com.jsowell.adapay.dto.WithdrawDTO;
|
|
|
|
|
|
import com.jsowell.adapay.service.AdapayService;
|
2023-07-17 16:44:04 +08:00
|
|
|
|
import com.jsowell.common.constant.CacheConstants;
|
2023-06-05 17:06:07 +08:00
|
|
|
|
import com.jsowell.common.constant.Constants;
|
2023-07-17 16:44:04 +08:00
|
|
|
|
import com.jsowell.common.core.redis.RedisCache;
|
2026-03-21 10:30:03 +08:00
|
|
|
|
import com.jsowell.common.enums.SoftwareProtocolEnum;
|
2025-01-15 09:05:55 +08:00
|
|
|
|
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
2026-03-21 10:30:03 +08:00
|
|
|
|
import com.jsowell.common.enums.ykc.PileChannelEntity;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.util.DateUtils;
|
2023-03-25 16:01:54 +08:00
|
|
|
|
import com.jsowell.common.util.StringUtils;
|
2025-03-25 14:33:58 +08:00
|
|
|
|
import com.jsowell.common.util.spring.SpringUtils;
|
2026-05-27 17:29:26 +08:00
|
|
|
|
import com.jsowell.pile.domain.*;
|
2026-03-21 10:30:03 +08:00
|
|
|
|
import com.jsowell.pile.domain.ykcCommond.ProofreadTimeCommand;
|
2026-05-27 17:29:26 +08:00
|
|
|
|
import com.jsowell.pile.domain.ykcCommond.PublishPileBillingTemplateCommand;
|
2023-06-03 17:04:15 +08:00
|
|
|
|
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
2023-07-26 19:41:13 +08:00
|
|
|
|
import com.jsowell.pile.service.*;
|
2025-01-15 09:05:55 +08:00
|
|
|
|
import com.jsowell.pile.vo.base.StationInfoVO;
|
2023-03-25 15:47:09 +08:00
|
|
|
|
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
2026-05-27 17:13:13 +08:00
|
|
|
|
import com.jsowell.quartz.service.AdapayUnsplitRecordHandleService;
|
2023-07-17 16:44:04 +08:00
|
|
|
|
import com.jsowell.thirdparty.amap.service.AMapService;
|
2025-08-15 09:34:38 +08:00
|
|
|
|
import com.jsowell.thirdparty.common.NotificationDTO;
|
|
|
|
|
|
import com.jsowell.thirdparty.common.NotificationService;
|
2023-03-25 11:10:15 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2026-03-11 17:55:20 +08:00
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
2023-03-25 16:01:54 +08:00
|
|
|
|
import java.math.BigDecimal;
|
2023-07-14 10:56:45 +08:00
|
|
|
|
import java.time.LocalDate;
|
2023-03-25 11:10:15 +08:00
|
|
|
|
import java.time.LocalDateTime;
|
2025-11-14 15:07:50 +08:00
|
|
|
|
import java.util.*;
|
2025-01-15 09:05:55 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
@Component("jsowellTask")
|
|
|
|
|
|
public class JsowellTask {
|
|
|
|
|
|
|
2025-02-13 14:00:09 +08:00
|
|
|
|
private final Logger log = LoggerFactory.getLogger(JsowellTask.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private OrderBasicInfoService orderBasicInfoService;
|
|
|
|
|
|
|
2026-03-21 10:30:03 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileBasicInfoService pileBasicInfoService;
|
|
|
|
|
|
|
2025-02-13 14:00:09 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileBillingTemplateService pileBillingTemplateService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private YKCPushCommandService ykcPushCommandService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileMerchantInfoService pileMerchantInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileStationInfoService pileStationInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
2025-08-15 09:34:38 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private NotificationService notificationService;
|
|
|
|
|
|
|
2025-02-13 14:00:09 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private AMapService aMapService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private AdapayService adapayService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private SettleOrderReportService settleOrderReportService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
|
|
|
|
|
|
2025-11-14 15:07:50 +08:00
|
|
|
|
// @Autowired
|
|
|
|
|
|
// private OrderUnsplitRecordService orderUnsplitRecordService;
|
|
|
|
|
|
|
2026-05-27 17:13:13 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private AdapayUnsplitRecordHandleService adapayUnsplitRecordHandleService;
|
|
|
|
|
|
|
2026-03-21 10:30:03 +08:00
|
|
|
|
private static final long YKC_DAILY_TIMECHECK_INTERVAL_MILLIS = 200L;
|
|
|
|
|
|
|
2025-03-25 14:33:58 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 设置挡板, PRE环境不执行
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void setBarrier() {
|
|
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
2025-03-25 14:50:11 +08:00
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-08-25 16:08:02 +08:00
|
|
|
|
// return;
|
2025-03-25 14:33:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-13 14:00:09 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 关闭15分钟未支付的订单
|
|
|
|
|
|
* close15MinutesOfUnpaidOrders
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void close15MinutesOfUnpaidOrders() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-03-25 14:50:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-02-13 14:00:09 +08:00
|
|
|
|
// log.info("关闭15分钟未支付的订单");
|
|
|
|
|
|
orderBasicInfoService.close15MinutesOfUnpaidOrders();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 关闭启动失败的订单
|
|
|
|
|
|
* 订单支付成功,在15分钟内未启动,
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void closeStartFailedOrder() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-08-25 16:18:46 +08:00
|
|
|
|
// return;
|
2025-03-25 14:50:11 +08:00
|
|
|
|
}
|
2025-02-13 14:00:09 +08:00
|
|
|
|
// 查询出最近2天支付成功,并且订单状态为未启动的订单
|
|
|
|
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addDays(new Date(), -2));
|
|
|
|
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
|
|
|
orderBasicInfoService.closeStartFailedOrder(startTime, endTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询预约充电的订单并启动
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void appointmentOrderStart() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-03-25 14:50:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-02-13 14:00:09 +08:00
|
|
|
|
// 查询出 已支付 设置预约充电 未启动 的订单
|
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
List<OrderBasicInfo> list = orderBasicInfoService.getReservedOrder(now);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("待启动充电订单:{}", list);
|
|
|
|
|
|
for (OrderBasicInfo orderInfo : list) {
|
|
|
|
|
|
// 下发充电桩设置指令
|
|
|
|
|
|
String pileSn = orderInfo.getPileSn();
|
|
|
|
|
|
// 发送启动充电指令前,再次下发计费模板
|
|
|
|
|
|
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
|
|
|
|
|
if (billingTemplateVO != null) {
|
|
|
|
|
|
PublishPileBillingTemplateCommand command = PublishPileBillingTemplateCommand.builder()
|
|
|
|
|
|
.billingTemplateVO(billingTemplateVO)
|
|
|
|
|
|
.pileSn(pileSn)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
ykcPushCommandService.pushPublishPileBillingTemplate(command);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 发送启动指令
|
|
|
|
|
|
String connectorCode = orderInfo.getConnectorCode();
|
|
|
|
|
|
String transactionCode = orderInfo.getTransactionCode();
|
|
|
|
|
|
BigDecimal payAmount = orderInfo.getPayAmount();
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
|
|
|
|
|
log.warn("appointmentOrderStart-远程启动充电, 充电桩编号和枪口号不能为空");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("appointmentOrderStart 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
|
|
|
|
|
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
|
|
|
|
|
.pileSn(pileSn)
|
|
|
|
|
|
.connectorCode(connectorCode)
|
|
|
|
|
|
.transactionCode(transactionCode)
|
|
|
|
|
|
.chargeAmount(payAmount)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-21 10:30:03 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 云快充1.6每日自动对时
|
|
|
|
|
|
* jsowellTask.dailyProofreadTimeForYkcV160()
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void dailyProofreadTimeForYkcV160() {
|
|
|
|
|
|
this.dailyProofreadTimeForYkcV160(YKC_DAILY_TIMECHECK_INTERVAL_MILLIS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 云快充1.6每日自动对时
|
|
|
|
|
|
* jsowellTask.dailyProofreadTimeForYkcV160(200)
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void dailyProofreadTimeForYkcV160(Long intervalMillis) {
|
|
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
|
|
|
|
|
log.debug("PRE环境不执行");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long sendIntervalMillis = intervalMillis == null || intervalMillis < 0 ? YKC_DAILY_TIMECHECK_INTERVAL_MILLIS : intervalMillis;
|
|
|
|
|
|
List<String> connectedPileSnList = PileChannelEntity.getPileSnListSnapshot().stream()
|
|
|
|
|
|
.filter(StringUtils::isNotBlank)
|
|
|
|
|
|
.sorted()
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(connectedPileSnList)) {
|
|
|
|
|
|
log.info("云快充1.6每日自动对时跳过: 当前无在线长连接");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int candidateCount = connectedPileSnList.size();
|
|
|
|
|
|
int sentCount = 0;
|
|
|
|
|
|
int skippedCount = 0;
|
|
|
|
|
|
int failedCount = 0;
|
|
|
|
|
|
log.info("云快充1.6每日自动对时开始, candidateCount:{}, intervalMillis:{}", candidateCount, sendIntervalMillis);
|
|
|
|
|
|
|
|
|
|
|
|
for (String pileSn : connectedPileSnList) {
|
|
|
|
|
|
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
|
|
|
|
|
|
if (pileBasicInfo == null) {
|
|
|
|
|
|
skippedCount++;
|
|
|
|
|
|
log.warn("云快充1.6每日自动对时跳过, pileSn:{}, reason: pile_basic_info_not_found", pileSn);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.equals(SoftwareProtocolEnum.YUN_KUAI_CHONGV160.getValue(), pileBasicInfo.getSoftwareProtocol())) {
|
|
|
|
|
|
skippedCount++;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
ProofreadTimeCommand command = ProofreadTimeCommand.builder().pileSn(pileSn).build();
|
|
|
|
|
|
ykcPushCommandService.pushProofreadTimeCommand(command);
|
|
|
|
|
|
sentCount++;
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
failedCount++;
|
|
|
|
|
|
log.error("云快充1.6每日自动对时失败, pileSn:{}", pileSn, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sendIntervalMillis > 0) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
Thread.sleep(sendIntervalMillis);
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
Thread.currentThread().interrupt();
|
|
|
|
|
|
log.warn("云快充1.6每日自动对时被中断, sentCount:{}, skippedCount:{}, failedCount:{}", sentCount, skippedCount, failedCount);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log.info("云快充1.6每日自动对时结束, candidateCount:{}, sentCount:{}, skippedCount:{}, failedCount:{}, intervalMillis:{}",
|
|
|
|
|
|
candidateCount, sentCount, skippedCount, failedCount, sendIntervalMillis);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-13 14:00:09 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 计算站点订单报表
|
|
|
|
|
|
* jsowellTask.calculateTheSiteOrdersReport()
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void calculateTheSiteOrdersReport() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-03-25 14:50:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-02-13 14:00:09 +08:00
|
|
|
|
// 查询出所有站点
|
|
|
|
|
|
PileStationInfo pileStationInfo = new PileStationInfo();
|
|
|
|
|
|
pileStationInfo.setDelFlag(Constants.ZERO);
|
|
|
|
|
|
// 查询未删除的站点列表
|
|
|
|
|
|
List<PileStationInfo> list = pileStationInfoService.selectPileStationInfoList(pileStationInfo);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
LocalDate yesterday = LocalDate.now().plusDays(-1);
|
|
|
|
|
|
// 计算每个站点前一天的报表
|
|
|
|
|
|
for (PileStationInfo stationInfo : list) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
settleOrderReportService.generateDailyOrderReports(stationInfo.getId() + "", yesterday.toString());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("计算站点订单报表 发生异常 stationId:{}", stationInfo.getId(), e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 站点的枪口数据推送到高德
|
|
|
|
|
|
* jsowellTask.pushToAMap()
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void pushToAMap() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-03-25 14:50:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-02-13 14:00:09 +08:00
|
|
|
|
Set<String> stationIds = redisCache.getCacheSet(CacheConstants.PUSH_STATION_CONNECTOR);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(stationIds)) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("推送到高德的stationId:{}", stationIds);
|
|
|
|
|
|
for (String stationId : stationIds) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
aMapService.pushChargingDeviceDynamics(stationId);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("推送到高德error", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 删除缓存
|
|
|
|
|
|
redisCache.deleteObject(CacheConstants.PUSH_STATION_CONNECTOR);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-07-10 10:05:37 +08:00
|
|
|
|
* 贵州省平台推送充电站实时功率 15分钟执行一次
|
2025-02-13 14:00:09 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public void pushStationRealTimePowerInfo() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
2025-08-18 08:40:07 +08:00
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-03-25 14:50:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-08-15 09:34:38 +08:00
|
|
|
|
|
2025-08-18 08:40:07 +08:00
|
|
|
|
List<String> thirdPartyTypeList = Lists.newArrayList(
|
|
|
|
|
|
ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode(),
|
2025-08-15 09:34:38 +08:00
|
|
|
|
ThirdPlatformTypeEnum.SI_CHUAN_PLATFORM.getTypeCode(),
|
|
|
|
|
|
ThirdPlatformTypeEnum.JI_LIN_PLATFORM.getTypeCode()
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
for (String thirdPartyType : thirdPartyTypeList) {
|
2025-08-15 08:58:09 +08:00
|
|
|
|
List<StationInfoVO> stationInfoVOS = thirdPartyStationRelationService.selectStationList(thirdPartyType);
|
2025-08-15 09:34:38 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(stationInfoVOS)) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2025-02-13 14:00:09 +08:00
|
|
|
|
|
2025-08-15 08:58:09 +08:00
|
|
|
|
List<String> stationIdList = stationInfoVOS.stream()
|
|
|
|
|
|
.map(StationInfoVO::getStationId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
2025-02-13 14:00:09 +08:00
|
|
|
|
|
2025-08-15 09:34:38 +08:00
|
|
|
|
for (String stationId : stationIdList) {
|
2025-08-15 09:50:38 +08:00
|
|
|
|
try {
|
|
|
|
|
|
NotificationDTO dto = new NotificationDTO();
|
|
|
|
|
|
dto.setStationId(stationId);
|
|
|
|
|
|
dto.setPlatformType(thirdPartyType);
|
|
|
|
|
|
notificationService.notificationStationPowerInfo(dto);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("平台类型:{},站点ID:{},推送充电站实时功率失败", thirdPartyType, stationId, e);
|
|
|
|
|
|
}
|
2025-08-15 09:34:38 +08:00
|
|
|
|
}
|
2025-08-15 08:58:09 +08:00
|
|
|
|
}
|
2025-07-10 10:05:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 推送统计信息 24小时执行一次
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void pushStatisticsInfo() {
|
|
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
2025-11-10 17:07:29 +08:00
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
|
|
|
|
|
log.debug("PRE环境不执行");
|
2025-07-10 10:05:37 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-18 08:40:07 +08:00
|
|
|
|
List<String> thirdPartyTypeList = Lists.newArrayList(
|
|
|
|
|
|
ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode(),
|
2025-08-15 09:42:37 +08:00
|
|
|
|
ThirdPlatformTypeEnum.SI_CHUAN_PLATFORM.getTypeCode(),
|
|
|
|
|
|
ThirdPlatformTypeEnum.JI_LIN_PLATFORM.getTypeCode()
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
for (String thirdPartyType : thirdPartyTypeList) {
|
|
|
|
|
|
List<StationInfoVO> stationInfoVOS = thirdPartyStationRelationService.selectStationList(thirdPartyType);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(stationInfoVOS)) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<String> stationIdList = stationInfoVOS.stream()
|
|
|
|
|
|
.map(StationInfoVO::getStationId)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
for (String stationId : stationIdList) {
|
2025-08-15 09:50:38 +08:00
|
|
|
|
try {
|
|
|
|
|
|
NotificationDTO dto = new NotificationDTO();
|
|
|
|
|
|
dto.setStationId(stationId);
|
|
|
|
|
|
dto.setPlatformType(thirdPartyType);
|
|
|
|
|
|
notificationService.notificationOperationStatsInfo(dto);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("平台类型:{},站点ID:{},推送统计信息失败", thirdPartyType, stationId, e);
|
|
|
|
|
|
}
|
2025-08-15 09:42:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-13 18:10:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-13 14:00:09 +08:00
|
|
|
|
/**
|
2025-02-21 15:50:15 +08:00
|
|
|
|
* 定时任务, 订单分账
|
2025-02-13 14:00:09 +08:00
|
|
|
|
* jsowellTask.processOrderSplitting()
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void processOrderSplitting() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-03-25 14:50:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-02-13 14:00:09 +08:00
|
|
|
|
// 查询运营商列表
|
|
|
|
|
|
List<PileMerchantInfo> pileMerchantInfos = pileMerchantInfoService.selectPileMerchantInfoList(null);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(pileMerchantInfos)) {
|
|
|
|
|
|
log.info("定时任务,处理订单分账, 未查询到运营商列表,直接返回");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取日期
|
|
|
|
|
|
LocalDate yesterday = LocalDate.now().plusDays(-1);
|
|
|
|
|
|
|
|
|
|
|
|
// 设置挡板,8月1号之后的订单按照实际进行分账
|
2025-02-21 15:50:15 +08:00
|
|
|
|
// LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
// LocalDateTime dateTime = LocalDateTime.of(2023, 8, 2, 0, 0, 0);
|
|
|
|
|
|
// if (now.isBefore(dateTime)) {
|
|
|
|
|
|
// log.info("当前时间:{}早于:{}, 不进行分账处理", DateUtils.formatDateTime(now), DateUtils.formatDateTime(dateTime));
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 调生成运营商日报方法
|
|
|
|
|
|
pileMerchantInfos.parallelStream().forEach(merchant -> {
|
|
|
|
|
|
try {
|
|
|
|
|
|
orderBasicInfoService.orderSplittingOperations(merchant.getId() + "", yesterday.toString());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("生成运营商日报异常, merchantId:{}", merchant.getId(), e);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生成运营商日报表
|
|
|
|
|
|
* jsowellTask.generateMerchantBill()
|
2025-03-05 16:07:47 +08:00
|
|
|
|
*
|
|
|
|
|
|
*
|
2025-02-21 15:50:15 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public void generateMerchantBill() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-03-25 14:50:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-02-21 15:50:15 +08:00
|
|
|
|
// 查询运营商列表
|
|
|
|
|
|
List<PileMerchantInfo> pileMerchantInfos = pileMerchantInfoService.selectPileMerchantInfoList(null);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(pileMerchantInfos)) {
|
|
|
|
|
|
log.info("定时任务,处理订单分账, 未查询到运营商列表,直接返回");
|
2025-02-13 14:00:09 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-02-21 15:50:15 +08:00
|
|
|
|
// 获取日期
|
|
|
|
|
|
LocalDate yesterday = LocalDate.now().plusDays(-1);
|
2025-02-13 14:00:09 +08:00
|
|
|
|
|
2025-02-20 16:50:30 +08:00
|
|
|
|
// 调生成运营商日报方法
|
2025-02-18 10:39:20 +08:00
|
|
|
|
pileMerchantInfos.parallelStream().forEach(merchant -> {
|
2025-02-20 15:44:35 +08:00
|
|
|
|
try {
|
|
|
|
|
|
orderBasicInfoService.generateMerchantBill(merchant.getId() + "", yesterday.toString());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("生成运营商日报异常, merchantId:{}", merchant.getId(), e);
|
|
|
|
|
|
}
|
2025-02-18 10:39:20 +08:00
|
|
|
|
});
|
2025-02-13 14:00:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-02-20 15:44:35 +08:00
|
|
|
|
* 定时任务,自动提现
|
|
|
|
|
|
* jsowellTask.automaticPayouts()
|
2025-02-13 14:00:09 +08:00
|
|
|
|
*/
|
2025-02-20 15:44:35 +08:00
|
|
|
|
public void automaticPayouts() {
|
2025-03-25 14:50:11 +08:00
|
|
|
|
String env = SpringUtils.getActiveProfile();
|
|
|
|
|
|
if (StringUtils.equalsIgnoreCase(env, "pre")) {
|
2025-03-25 14:57:25 +08:00
|
|
|
|
log.debug("PRE环境不执行");
|
2025-03-25 14:50:11 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询开启自动提现运营商列表
|
2025-03-13 13:43:30 +08:00
|
|
|
|
// List<PileMerchantInfo> pileMerchantInfos = pileMerchantInfoService.selectPileMerchantInfoList(null);
|
|
|
|
|
|
List<PileMerchantInfo> pileMerchantInfos = pileMerchantInfoService.selectAutoWithdrawalMerchantInfoList();
|
2025-02-20 15:44:35 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(pileMerchantInfos)) {
|
|
|
|
|
|
log.info("定时任务,自动提现, 未查询到运营商列表,直接返回");
|
|
|
|
|
|
return;
|
2025-02-13 11:49:52 +08:00
|
|
|
|
}
|
2025-02-20 15:44:35 +08:00
|
|
|
|
|
|
|
|
|
|
// 调提现方法
|
|
|
|
|
|
pileMerchantInfos.parallelStream().forEach(merchant -> {
|
|
|
|
|
|
try {
|
|
|
|
|
|
WithdrawDTO dto = new WithdrawDTO();
|
|
|
|
|
|
dto.setMerchantId(merchant.getId() + "");
|
|
|
|
|
|
dto.setFeeAmt("0");
|
|
|
|
|
|
adapayService.drawCash(dto);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("生成运营商日报异常, merchantId:{}", merchant.getId(), e);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-02-13 11:49:52 +08:00
|
|
|
|
}
|
2025-02-20 15:44:35 +08:00
|
|
|
|
|
2025-04-16 15:50:26 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 处理未分帐订单
|
2025-04-17 10:03:33 +08:00
|
|
|
|
* jsowellTask.processUnSettledOrder()
|
2025-04-16 15:50:26 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public void processUnSettledOrder() {
|
2026-05-27 17:29:26 +08:00
|
|
|
|
adapayUnsplitRecordHandleService.processUnSettledOrder();
|
2025-11-14 14:48:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-11 17:55:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 处理adapay_unsplit_record待分账数据,统一分账到memberId=0
|
|
|
|
|
|
* 依赖queryList(),请先完成settle_amount/due_refund_amount等字段补齐
|
|
|
|
|
|
* jsowellTask.processUnsplitRecordToDefaultMember()
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void processUnsplitRecordToDefaultMember() {
|
2026-05-27 17:13:13 +08:00
|
|
|
|
adapayUnsplitRecordHandleService.processUnsplitRecordToDefaultMember();
|
2026-03-11 17:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 处理adapay_unsplit_record待分账数据,统一分账到memberId=0
|
|
|
|
|
|
* jsowellTask.processUnsplitRecordToDefaultMember(wechatAppId, pageSize)
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void processUnsplitRecordToDefaultMember(String wechatAppId, Integer pageSize) {
|
2026-05-27 17:13:13 +08:00
|
|
|
|
adapayUnsplitRecordHandleService.processUnsplitRecordToDefaultMember(wechatAppId, pageSize);
|
2026-03-11 17:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 从Excel导入adapay_unsplit_record,并补齐缺失字段
|
|
|
|
|
|
* 默认文件路径:doc/万车充小程序-未分账明细.xlsx
|
|
|
|
|
|
* jsowellTask.importAdapayUnsplitRecordAndCompleteFields()
|
|
|
|
|
|
*/
|
2026-03-12 15:23:32 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 从默认路径导入未分账明细并补齐缺失字段(无参入口)
|
|
|
|
|
|
* 默认读取 doc/万车充小程序-未分账明细.xlsx(相对于工作目录)
|
|
|
|
|
|
* jsowellTask.importAdapayUnsplitRecordAndCompleteFields()
|
|
|
|
|
|
*/
|
2026-03-11 17:55:20 +08:00
|
|
|
|
public void importAdapayUnsplitRecordAndCompleteFields() {
|
2026-05-27 17:13:13 +08:00
|
|
|
|
adapayUnsplitRecordHandleService.importAdapayUnsplitRecordAndCompleteFields();
|
2026-03-11 17:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-12 16:12:34 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 补齐 adapay_unsplit_record 表中缺失字段(独立入口,可单独作为定时任务调用)
|
|
|
|
|
|
* 以指定时间范围内的未分账记录为目标,补齐 orderCode、退款金额、结算金额、桩类型
|
|
|
|
|
|
* jsowellTask.completeAdapayUnsplitRecordFields(startTime, endTime)
|
|
|
|
|
|
* 示例:jsowellTask.completeAdapayUnsplitRecordFields('2024-01-01 00:00:00', '2025-12-31 23:59:59')
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void completeAdapayUnsplitRecordFields(String startTime, String endTime) {
|
2026-05-27 17:13:13 +08:00
|
|
|
|
adapayUnsplitRecordHandleService.completeAdapayUnsplitRecordFields(startTime, endTime);
|
2026-03-12 16:12:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-11 17:55:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 从Excel导入adapay_unsplit_record,并补齐缺失字段
|
2026-03-12 15:23:32 +08:00
|
|
|
|
* 流程:
|
|
|
|
|
|
* 1. 校验文件路径(相对路径自动拼接工作目录转为绝对路径)
|
2026-05-26 16:17:02 +08:00
|
|
|
|
* 2. 解析Excel,逐行转换为 AdapayUnsplitRecord;
|
|
|
|
|
|
* 以 paymentId 为业务唯一键,已存在则按主键更新,不存在则新增
|
2026-03-12 15:23:32 +08:00
|
|
|
|
* 3. 以导入数据的支付时间范围为条件,分页查询已入库记录,补齐 orderCode/退款金额/结算金额/桩类型等缺失字段
|
2026-03-11 17:55:20 +08:00
|
|
|
|
* jsowellTask.importAdapayUnsplitRecordAndCompleteFields(文件路径)
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void importAdapayUnsplitRecordAndCompleteFields(String filePath) {
|
2026-05-27 17:13:13 +08:00
|
|
|
|
adapayUnsplitRecordHandleService.importAdapayUnsplitRecordAndCompleteFields(filePath);
|
2026-03-11 17:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-04 16:37:58 +08:00
|
|
|
|
public void updateOrderReview() {
|
|
|
|
|
|
LocalDate yesterday = DateUtils.getYesterday();
|
|
|
|
|
|
LocalDateTime start = yesterday.atStartOfDay();
|
|
|
|
|
|
LocalDateTime end = yesterday.atTime(23, 59, 59);
|
2026-02-05 14:51:20 +08:00
|
|
|
|
|
2026-04-27 13:52:24 +08:00
|
|
|
|
orderBasicInfoService.updateOrderReviewFlagTemp(start, end, null, null);
|
2026-02-04 16:37:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|