@@ -32,7 +32,7 @@ public class BydDashboardBatchSyncTask extends AbstractManager { | |||
@Resource | |||
private AflBydDashboardService aflBydDashboardService; | |||
@Scheduled(cron = "0 0/30 1-4 * * ?") | |||
// @Scheduled(cron = "0 0/30 1-4 * * ?") | |||
public void dashboardBatchSync() { | |||
// | |||
final List<AflBydDashboard> dashboards = aflBydDashboardRepo.findAll(((root, query, cb) -> query.where( |
@@ -0,0 +1,59 @@ | |||
package com.qtzl.alterSales.manager.quartz; | |||
import cn.com.taiji.common.manager.AbstractManager; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import com.qtzl.alterSales.dao.entity.second.AflBydDashboard; | |||
import com.qtzl.alterSales.dao.repo.jpa.second.AflBydDashboardRepo; | |||
import com.qtzl.alterSales.manager.enums.AflBydDashboardPushStateEnum; | |||
import com.qtzl.alterSales.manager.service.AflBydDashboardService; | |||
import com.qtzl.alterSales.manager.service.byd.vo.BydDashBoardResponse; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.data.domain.Sort; | |||
import org.springframework.scheduling.annotation.Scheduled; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.util.CollectionUtils; | |||
import javax.annotation.Resource; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
/*** | |||
* <p> | |||
* 比亚迪看板数据批量同步. 临时处理 | |||
* </p> | |||
* @author hou yi | |||
* {@code @date} 2024/3/15 9:36 | |||
**/ | |||
@Component | |||
public class BydDashboardBatchSyncTempTask extends AbstractManager { | |||
private static final Logger log = LoggerFactory.getLogger(BydDashboardBatchSyncTempTask.class); | |||
@Resource | |||
private AflBydDashboardRepo aflBydDashboardRepo; | |||
@Resource | |||
private AflBydDashboardService aflBydDashboardService; | |||
@Scheduled(cron = "0 0/5 * * * ?") | |||
public void dashboardBatchSync() throws ServiceHandleException { | |||
// | |||
final List<AflBydDashboard> dashboards = aflBydDashboardRepo.findAll(((root, query, cb) -> query.where( | |||
cb.notEqual(root.<AflBydDashboardPushStateEnum>get("pushState"), AflBydDashboardPushStateEnum.PUSH_SUCCESS) | |||
).getRestriction()), Sort.by(Sort.Direction.ASC, "insertTime")); | |||
log.info("比亚迪看板数据同步-临时,本次共处理批次数:" + dashboards.size()); | |||
if (CollectionUtils.isEmpty(dashboards)) { | |||
log.info("比亚迪看板数据同步-临时,已全部处理完成"); | |||
return; | |||
} | |||
final AflBydDashboard dashboard = dashboards.get(0); | |||
final BydDashBoardResponse batchSync = aflBydDashboardService.batchSync(dashboard); | |||
dashboard.setPushState(AflBydDashboardPushStateEnum.PUSH_SUCCESS); | |||
dashboard.setPushDate(LocalDateTime.now()); | |||
dashboard.setBydState(batchSync.getRespondData()); | |||
dashboard.setPushMsg(null); | |||
aflBydDashboardRepo.save(dashboard); | |||
log.info("比亚迪看板数据同步-临时,处理完成"); | |||
} | |||
} |
@@ -47,7 +47,6 @@ public class AflCancelOrderServiceImpl implements AflCancelOrderService { | |||
if (!CollectionUtils.isEmpty(applyOrders)) { | |||
applyOrders.forEach(vo -> vo.setSealedStatus(1)); | |||
etcApplyOrderRepo.saveAll(applyOrders); | |||
return; | |||
} | |||
// 处理注册表 |
@@ -129,16 +129,18 @@ public class BydServiceImpl extends BydAbstract implements BydService { | |||
for (BydOrderVehicleInfoVo infoVo : orderVehicleInfoVo) { | |||
// 查询首次获取验证码时间 | |||
userLoginInfos = aflOrderInfoRepo.getFirstLoginTime(infoVo.getPlateNo()); | |||
if (CollectionUtils.isEmpty(userLoginInfos)) { | |||
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("处理比亚迪看板数据时, 车牌号未查到订单或登录信息..." + infoVo.getPlateNo()); | |||
} | |||
// if (CollectionUtils.isEmpty(userLoginInfos)) { | |||
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("处理比亚迪看板数据时, 车牌号未查到订单或登录信息..." + infoVo.getPlateNo()); | |||
// } | |||
final AflBydBrandConfig brandConfig = brandConfigs.stream().filter(vo -> vo.getBrandName().equals(infoVo.getVehicleModel())).findFirst().orElse(null); | |||
String source = null == brandConfig ? getSource(brandConfigs, infoVo.getVin()) : brandConfig.getBrandCode(); | |||
userLoginInfo = userLoginInfos.stream().max(Comparator.comparing(AflUserLoginInfo::getInsertTime)).orElse(null); | |||
userLoginInfo = CollectionUtils.isEmpty(userLoginInfos) ? null : userLoginInfos.stream().max(Comparator.comparing(AflUserLoginInfo::getInsertTime)).orElse(null); | |||
// 查询绑定支付渠道时间 | |||
final LocalDateTime bindPayTime = getBindPayTime(infoVo.getPlateNo(), infoVo.getPlateColor()); | |||
dashboardDetails.add(new AflBydDashboardDetail(dashboard.getId(), infoVo.getVin(), infoVo.getPlateNo(), infoVo.getPlateColor(), infoVo.getOrderNo(), | |||
null != bindPayTime ? DateTools.getDate(bindPayTime) : infoVo.getCreateTime(), DateTools.getDate(userLoginInfo.getInsertTime()), infoVo.getSuccessActivationTime(), source)); | |||
null != bindPayTime ? DateTools.getDate(bindPayTime) : infoVo.getCreateTime(), | |||
null != userLoginInfo && null != userLoginInfo.getInsertTime() ? DateTools.getDate(userLoginInfo.getInsertTime()) : DateTools.addSecond(infoVo.getCreateTime(), -30), | |||
infoVo.getSuccessActivationTime(), source)); | |||
} | |||
} | |||
@@ -146,6 +146,17 @@ public class DateTools { | |||
return getDate(localDate.atTime(23, 59, 59, 0)); | |||
} | |||
/** | |||
* 获取日期前一天的结束时间 - 23:59:59 | |||
* | |||
* @param date | |||
* @return | |||
*/ | |||
public static Date getDayEnding(Date date) { | |||
LocalDate localDate = getLocalDate(date); | |||
return getDate(localDate.atTime(23, 59, 59, 0)); | |||
} | |||
/** | |||
* 获取日期所在年末的23:59:59 | |||
* |
@@ -12,6 +12,7 @@ import com.qtzl.alterSales.manager.service.AflBydDashboardService; | |||
import com.qtzl.alterSales.manager.service.byd.BydService; | |||
import com.qtzl.alterSales.manager.service.byd.vo.BydDashBoardResponse; | |||
import com.qtzl.alterSales.manager.service.byd.vo.BydPushDataResultRequest; | |||
import com.qtzl.alterSales.manager.tools.DateTools; | |||
import com.qtzl.alterSales.manager.tools.RedisUtils; | |||
import com.qtzl.alterSales.manager.vo.BydOrderVehicleInfoVo; | |||
import org.junit.Test; | |||
@@ -23,6 +24,7 @@ import javax.annotation.Resource; | |||
import java.text.ParseException; | |||
import java.text.SimpleDateFormat; | |||
import java.time.LocalDateTime; | |||
import java.util.Date; | |||
import java.util.List; | |||
/*** | |||
@@ -103,6 +105,15 @@ public class SaleTest { | |||
public void bydDataIntegration() throws ParseException, ServiceHandleException { | |||
// 指定时间跑对应版本的数据。按天出 | |||
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
bydService.dataIntegration(format.parse("2023-11-02 00:00:00"), format.parse("2024-03-01 23:59:59")); | |||
Date parse = format.parse("2023-11-15 00:00:00"); | |||
while (true){ | |||
final String formatted = format.format(parse); | |||
if (formatted.contains("2024-04-16")){ | |||
break; | |||
} | |||
System.out.println("当前处理 " + formatted +" 的数据"); | |||
bydService.dataIntegration(parse, DateTools.getDayEnding(parse)); | |||
parse = DateTools.addDays(parse, 1); | |||
} | |||
} | |||
} |