mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
update 添加每日对时定时任务
This commit is contained in:
@@ -14,16 +14,20 @@ import com.jsowell.common.YouDianUtils;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.SoftwareProtocolEnum;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.PileChannelEntity;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.spring.SpringUtils;
|
||||
import com.jsowell.pile.domain.AdapayUnsplitRecord;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PileBasicInfo;
|
||||
import com.jsowell.pile.domain.PileMerchantInfo;
|
||||
import com.jsowell.pile.domain.PileStationInfo;
|
||||
import com.jsowell.pile.domain.ykcCommond.PublishPileBillingTemplateCommand;
|
||||
import com.jsowell.pile.domain.ykcCommond.ProofreadTimeCommand;
|
||||
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.AdapayUnsplitRecordVO;
|
||||
@@ -57,6 +61,9 @@ public class JsowellTask {
|
||||
@Autowired
|
||||
private OrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@@ -93,6 +100,8 @@ public class JsowellTask {
|
||||
@Autowired
|
||||
private AdapayUnsplitRecordService adapayUnsplitRecordService;
|
||||
|
||||
private static final long YKC_DAILY_TIMECHECK_INTERVAL_MILLIS = 200L;
|
||||
|
||||
/**
|
||||
* 设置挡板, PRE环境不执行
|
||||
*/
|
||||
@@ -182,6 +191,77 @@ public class JsowellTask {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 云快充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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算站点订单报表
|
||||
* jsowellTask.calculateTheSiteOrdersReport()
|
||||
|
||||
Reference in New Issue
Block a user