mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
格式化
This commit is contained in:
@@ -36,205 +36,208 @@ import java.util.stream.Collectors;
|
|||||||
@Component("jsowellTask")
|
@Component("jsowellTask")
|
||||||
public class JsowellTask {
|
public class JsowellTask {
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(JsowellTask.class);
|
private final Logger log = LoggerFactory.getLogger(JsowellTask.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderBasicInfoService orderBasicInfoService;
|
private OrderBasicInfoService orderBasicInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileBillingTemplateService pileBillingTemplateService;
|
private PileBillingTemplateService pileBillingTemplateService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private YKCPushCommandService ykcPushCommandService;
|
private YKCPushCommandService ykcPushCommandService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileMerchantInfoService pileMerchantInfoService;
|
private PileMerchantInfoService pileMerchantInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileStationInfoService pileStationInfoService;
|
private PileStationInfoService pileStationInfoService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AMapService aMapService;
|
private AMapService aMapService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AdapayService adapayService;
|
private AdapayService adapayService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SettleOrderReportService settleOrderReportService;
|
private SettleOrderReportService settleOrderReportService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
private ThirdPartyStationRelationService thirdPartyStationRelationService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭15分钟未支付的订单
|
* 关闭15分钟未支付的订单
|
||||||
* close15MinutesOfUnpaidOrders
|
* close15MinutesOfUnpaidOrders
|
||||||
*/
|
*/
|
||||||
public void close15MinutesOfUnpaidOrders() {
|
public void close15MinutesOfUnpaidOrders() {
|
||||||
// log.info("关闭15分钟未支付的订单");
|
// log.info("关闭15分钟未支付的订单");
|
||||||
orderBasicInfoService.close15MinutesOfUnpaidOrders();
|
orderBasicInfoService.close15MinutesOfUnpaidOrders();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭启动失败的订单
|
* 关闭启动失败的订单
|
||||||
* 订单支付成功,在15分钟内未启动,
|
* 订单支付成功,在15分钟内未启动,
|
||||||
*/
|
*/
|
||||||
public void closeStartFailedOrder() {
|
public void closeStartFailedOrder() {
|
||||||
// 查询出最近2天支付成功,并且订单状态为未启动的订单
|
// 查询出最近2天支付成功,并且订单状态为未启动的订单
|
||||||
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addDays(new Date(), -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());
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
||||||
orderBasicInfoService.closeStartFailedOrder(startTime, endTime);
|
orderBasicInfoService.closeStartFailedOrder(startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询预约充电的订单并启动
|
* 查询预约充电的订单并启动
|
||||||
*/
|
*/
|
||||||
public void appointmentOrderStart() {
|
public void appointmentOrderStart() {
|
||||||
// 查询出 已支付 设置预约充电 未启动 的订单
|
// 查询出 已支付 设置预约充电 未启动 的订单
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
List<OrderBasicInfo> list = orderBasicInfoService.getReservedOrder(now);
|
List<OrderBasicInfo> list = orderBasicInfoService.getReservedOrder(now);
|
||||||
if (CollectionUtils.isEmpty(list)) {
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("待启动充电订单:{}", list);
|
log.info("待启动充电订单:{}", list);
|
||||||
for (OrderBasicInfo orderInfo : list) {
|
for (OrderBasicInfo orderInfo : list) {
|
||||||
// 下发充电桩设置指令
|
// 下发充电桩设置指令
|
||||||
String pileSn = orderInfo.getPileSn();
|
String pileSn = orderInfo.getPileSn();
|
||||||
// 发送启动充电指令前,再次下发计费模板
|
// 发送启动充电指令前,再次下发计费模板
|
||||||
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
||||||
if (billingTemplateVO != null) {
|
if (billingTemplateVO != null) {
|
||||||
PublishPileBillingTemplateCommand command = PublishPileBillingTemplateCommand.builder()
|
PublishPileBillingTemplateCommand command = PublishPileBillingTemplateCommand.builder()
|
||||||
.billingTemplateVO(billingTemplateVO)
|
.billingTemplateVO(billingTemplateVO)
|
||||||
.pileSn(pileSn)
|
.pileSn(pileSn)
|
||||||
.build();
|
.build();
|
||||||
ykcPushCommandService.pushPublishPileBillingTemplate(command);
|
ykcPushCommandService.pushPublishPileBillingTemplate(command);
|
||||||
}
|
}
|
||||||
// 发送启动指令
|
// 发送启动指令
|
||||||
String connectorCode = orderInfo.getConnectorCode();
|
String connectorCode = orderInfo.getConnectorCode();
|
||||||
String transactionCode = orderInfo.getTransactionCode();
|
String transactionCode = orderInfo.getTransactionCode();
|
||||||
BigDecimal payAmount = orderInfo.getPayAmount();
|
BigDecimal payAmount = orderInfo.getPayAmount();
|
||||||
|
|
||||||
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
if (StringUtils.isEmpty(pileSn) || StringUtils.isEmpty(connectorCode)) {
|
||||||
log.warn("appointmentOrderStart-远程启动充电, 充电桩编号和枪口号不能为空");
|
log.warn("appointmentOrderStart-远程启动充电, 充电桩编号和枪口号不能为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("appointmentOrderStart 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
log.info("appointmentOrderStart 远程启动充电, 桩号:{}, 枪口号:{}", pileSn, connectorCode);
|
||||||
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
StartChargingCommand startChargingCommand = StartChargingCommand.builder()
|
||||||
.pileSn(pileSn)
|
.pileSn(pileSn)
|
||||||
.connectorCode(connectorCode)
|
.connectorCode(connectorCode)
|
||||||
.transactionCode(transactionCode)
|
.transactionCode(transactionCode)
|
||||||
.chargeAmount(payAmount)
|
.chargeAmount(payAmount)
|
||||||
.build();
|
.build();
|
||||||
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
ykcPushCommandService.pushStartChargingCommand(startChargingCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算站点订单报表
|
* 计算站点订单报表
|
||||||
* jsowellTask.calculateTheSiteOrdersReport()
|
* jsowellTask.calculateTheSiteOrdersReport()
|
||||||
*/
|
*/
|
||||||
public void calculateTheSiteOrdersReport() {
|
public void calculateTheSiteOrdersReport() {
|
||||||
// 查询出所有站点
|
// 查询出所有站点
|
||||||
PileStationInfo pileStationInfo = new PileStationInfo();
|
PileStationInfo pileStationInfo = new PileStationInfo();
|
||||||
pileStationInfo.setDelFlag(Constants.ZERO);
|
pileStationInfo.setDelFlag(Constants.ZERO);
|
||||||
// 查询未删除的站点列表
|
// 查询未删除的站点列表
|
||||||
List<PileStationInfo> list = pileStationInfoService.selectPileStationInfoList(pileStationInfo);
|
List<PileStationInfo> list = pileStationInfoService.selectPileStationInfoList(pileStationInfo);
|
||||||
if (CollectionUtils.isEmpty(list)) {
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LocalDate yesterday = LocalDate.now().plusDays(-1);
|
LocalDate yesterday = LocalDate.now().plusDays(-1);
|
||||||
// 计算每个站点前一天的报表
|
// 计算每个站点前一天的报表
|
||||||
for (PileStationInfo stationInfo : list) {
|
for (PileStationInfo stationInfo : list) {
|
||||||
try {
|
try {
|
||||||
settleOrderReportService.generateDailyOrderReports(stationInfo.getId() + "", yesterday.toString());
|
settleOrderReportService.generateDailyOrderReports(stationInfo.getId() + "", yesterday.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("计算站点订单报表 发生异常 stationId:{}", stationInfo.getId(), e);
|
log.error("计算站点订单报表 发生异常 stationId:{}", stationInfo.getId(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 站点的枪口数据推送到高德
|
* 站点的枪口数据推送到高德
|
||||||
* jsowellTask.pushToAMap()
|
* jsowellTask.pushToAMap()
|
||||||
*/
|
*/
|
||||||
public void pushToAMap() {
|
public void pushToAMap() {
|
||||||
Set<String> stationIds = redisCache.getCacheSet(CacheConstants.PUSH_STATION_CONNECTOR);
|
Set<String> stationIds = redisCache.getCacheSet(CacheConstants.PUSH_STATION_CONNECTOR);
|
||||||
if (CollectionUtils.isEmpty(stationIds)) {
|
if (CollectionUtils.isEmpty(stationIds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("推送到高德的stationId:{}", stationIds);
|
log.info("推送到高德的stationId:{}", stationIds);
|
||||||
for (String stationId : stationIds) {
|
for (String stationId : stationIds) {
|
||||||
try {
|
try {
|
||||||
aMapService.pushChargingDeviceDynamics(stationId);
|
aMapService.pushChargingDeviceDynamics(stationId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("推送到高德error", e);
|
log.error("推送到高德error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
redisCache.deleteObject(CacheConstants.PUSH_STATION_CONNECTOR);
|
redisCache.deleteObject(CacheConstants.PUSH_STATION_CONNECTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 贵州省平台推送充电站实时功率
|
* 贵州省平台推送充电站实时功率
|
||||||
*/
|
*/
|
||||||
public void pushStationRealTimePowerInfo(){
|
public void pushStationRealTimePowerInfo() {
|
||||||
// 查询出要推送的站点(贵州、)
|
// 查询出要推送的站点(贵州、)
|
||||||
String thirdPartyType = ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode();
|
String thirdPartyType = ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode();
|
||||||
List<StationInfoVO> stationInfoVOS = thirdPartyStationRelationService.selectStationList(thirdPartyType);
|
List<StationInfoVO> stationInfoVOS = thirdPartyStationRelationService.selectStationList(thirdPartyType);
|
||||||
|
|
||||||
List<String> stationIdList = stationInfoVOS.stream()
|
List<String> stationIdList = stationInfoVOS.stream()
|
||||||
.map(StationInfoVO::getStationId)
|
.map(StationInfoVO::getStationId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
GuiZhouPlatformServiceImpl guiZhouPlatformService = new GuiZhouPlatformServiceImpl();
|
GuiZhouPlatformServiceImpl guiZhouPlatformService = new GuiZhouPlatformServiceImpl();
|
||||||
guiZhouPlatformService.notificationPowerInfo(stationIdList);
|
guiZhouPlatformService.notificationPowerInfo(stationIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务,处理订单分账
|
* 定时任务,处理订单分账
|
||||||
* jsowellTask.processOrderSplitting()
|
* jsowellTask.processOrderSplitting()
|
||||||
*/
|
*/
|
||||||
public void processOrderSplitting() {
|
public void processOrderSplitting() {
|
||||||
// 查询运营商列表
|
// 查询运营商列表
|
||||||
List<PileMerchantInfo> pileMerchantInfos = pileMerchantInfoService.selectPileMerchantInfoList(null);
|
List<PileMerchantInfo> pileMerchantInfos = pileMerchantInfoService.selectPileMerchantInfoList(null);
|
||||||
if (CollectionUtils.isEmpty(pileMerchantInfos)) {
|
if (CollectionUtils.isEmpty(pileMerchantInfos)) {
|
||||||
log.info("定时任务,处理订单分账, 未查询到运营商列表,直接返回");
|
log.info("定时任务,处理订单分账, 未查询到运营商列表,直接返回");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 获取日期
|
// 获取日期
|
||||||
LocalDate yesterday = LocalDate.now().plusDays(-1);
|
LocalDate yesterday = LocalDate.now().plusDays(-1);
|
||||||
|
|
||||||
// 设置挡板,8月1号之后的订单按照实际进行分账
|
// 设置挡板,8月1号之后的订单按照实际进行分账
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime dateTime = LocalDateTime.of(2023, 8, 2, 0, 0, 0);
|
LocalDateTime dateTime = LocalDateTime.of(2023, 8, 2, 0, 0, 0);
|
||||||
if (now.isBefore(dateTime)) {
|
if (now.isBefore(dateTime)) {
|
||||||
log.info("当前时间:{}早于:{}, 不进行分账处理", DateUtils.formatDateTime(now), DateUtils.formatDateTime(dateTime));
|
log.info("当前时间:{}早于:{}, 不进行分账处理", DateUtils.formatDateTime(now), DateUtils.formatDateTime(dateTime));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调分账方法
|
// 调分账方法
|
||||||
pileMerchantInfos.parallelStream().forEach(merchant -> {
|
pileMerchantInfos.parallelStream().forEach(merchant -> {
|
||||||
try {
|
try {
|
||||||
orderBasicInfoService.orderSplittingOperations(merchant.getId()+"", yesterday.toString());
|
orderBasicInfoService.orderSplittingOperations(merchant.getId() + "", yesterday.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("处理订单分账异常, merchantId:{}", merchant.getId(), e);
|
log.error("处理订单分账异常, merchantId:{}", merchant.getId(), e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// TODO 换为实时分账后, 此方法改为 自动提现并计算前一天的分账信息
|
// TODO 换为实时分账后, 此方法改为 自动提现并计算前一天的分账信息
|
||||||
}
|
// pileMerchantInfos.parallelStream().forEach(merchant -> {
|
||||||
|
// automaticPayouts(merchant.getId() + "");
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动提现并计算前一天的分账信息
|
* 自动提现并计算前一天的分账信息
|
||||||
* automaticPayouts
|
* automaticPayouts
|
||||||
*/
|
*/
|
||||||
private void automaticPayouts(String merchantId) {
|
private void automaticPayouts(String merchantId) {
|
||||||
WithdrawDTO dto = new WithdrawDTO();
|
WithdrawDTO dto = new WithdrawDTO();
|
||||||
dto.setMerchantId(merchantId);
|
dto.setMerchantId(merchantId);
|
||||||
dto.setFeeAmt("0");
|
dto.setFeeAmt("0");
|
||||||
try {
|
try {
|
||||||
adapayService.drawCash(dto);
|
adapayService.drawCash(dto);
|
||||||
} catch (BaseAdaPayException e) {
|
} catch (BaseAdaPayException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user