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:
@@ -152,6 +152,10 @@ public class PileChannelEntity {
|
||||
return manager.remove(pileSn, currentCtx);
|
||||
}
|
||||
|
||||
public static List<String> getPileSnListSnapshot() {
|
||||
return new ArrayList<>(manager.keySet());
|
||||
}
|
||||
|
||||
public static void removeByChannelId(String channelId){
|
||||
if (StringUtils.isBlank(channelId)) {
|
||||
return;
|
||||
|
||||
@@ -7,8 +7,11 @@ import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import com.jsowell.pile.dto.SavePileMsgDTO;
|
||||
import com.jsowell.pile.service.PileMsgRecordService;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -24,6 +27,9 @@ import java.util.Date;
|
||||
public class TimeCheckSettingResponseHandler extends AbstractYkcHandler {
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.TIME_CHECK_SETTING_ANSWER_CODE.getBytes());
|
||||
|
||||
@Autowired
|
||||
private PileMsgRecordService pileMsgRecordService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
YKCOperateFactory.register(type, this);
|
||||
@@ -50,7 +56,18 @@ public class TimeCheckSettingResponseHandler extends AbstractYkcHandler {
|
||||
length = 7;
|
||||
byte[] currentTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
Date date = Cp56Time2aUtil.byte2Hdate(currentTimeByteArr);
|
||||
log.info("[===对时设置充电桩应答===], pileSn:{}, channelId:{}, 充电桩当前时间:{}", pileSn, channel.channel().id().asShortText(), DateUtils.formatDateTime(date));
|
||||
String deviceTime = DateUtils.formatDateTime(date);
|
||||
String platformTime = DateUtils.getDateTime();
|
||||
SavePileMsgDTO dto = SavePileMsgDTO.builder()
|
||||
.pileSn(pileSn)
|
||||
.connectorCode("")
|
||||
.transactionCode("")
|
||||
.frameType(type)
|
||||
.jsonMsg("对时设置应答: deviceTime=" + deviceTime + ", platformTime=" + platformTime)
|
||||
.originalMsg(ykcDataProtocol.getHEXString())
|
||||
.build();
|
||||
pileMsgRecordService.save(dto);
|
||||
log.info("[===对时设置充电桩应答===], pileSn:{}, channelId:{}, 充电桩当前时间:{}, 平台当前时间:{}", pileSn, channel.channel().id().asShortText(), deviceTime, platformTime);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,8 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_RESTART_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_CONTROL_START_CHARGING_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_CONTROL_STOP_CHARGING_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE.getBytes())
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.TIME_CHECK_SETTING_CODE.getBytes())
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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