任务日志堆栈打印;充电时间取绝对值

This commit is contained in:
ZZ 2021-12-21 13:36:25 +08:00
parent 0c29d1fcb4
commit 69a0671e8e
2 changed files with 32 additions and 1 deletions

View File

@ -109,7 +109,7 @@ public class CDChargeOrderInfo4BonusReq {
if (starttime != null && endtime != null) {
cl = Math.toIntExact((endtime.getTime() - starttime.getTime()) / 1000);
}
this.chargeLast = cl;
this.chargeLast = Math.abs(cl);
this.meterValueStart = xhpcHistoryOrder.getMeterValueStartEvcs();
this.meterValueEnd = xhpcHistoryOrder.getMeterValueEndEvcs();
}

View File

@ -0,0 +1,31 @@
package com.xhpc.evcs.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.task.TaskSchedulerCustomizer;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.ErrorHandler;
@Configuration
public class TaskLogConfig implements TaskSchedulerCustomizer {
@Override
public void customize(ThreadPoolTaskScheduler taskScheduler) {
taskScheduler.setErrorHandler(new CustomErrorHandler());
}
private static class CustomErrorHandler implements ErrorHandler {
private static final Logger logger = LoggerFactory.getLogger(CustomErrorHandler.class);
@Override
public void handleError(Throwable t) {
logger.error("Scheduled task threw an exception: {}", t.getMessage(), t);
}
}
}