|
|
@ -5,18 +5,23 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.ssf.mysqloracletest.domain.TMotorvehicle;
|
|
|
|
import com.ssf.mysqloracletest.domain.TMotorvehicle;
|
|
|
|
|
|
|
|
import com.ssf.mysqloracletest.domain.TStrhEntityInfoKs;
|
|
|
|
|
|
|
|
import com.ssf.mysqloracletest.domain.TransitUserRecord;
|
|
|
|
import com.ssf.mysqloracletest.domain.TransitVehicleRecord;
|
|
|
|
import com.ssf.mysqloracletest.domain.TransitVehicleRecord;
|
|
|
|
import com.ssf.mysqloracletest.service.TMotorvehicleService;
|
|
|
|
import com.ssf.mysqloracletest.service.TMotorvehicleService;
|
|
|
|
import com.ssf.mysqloracletest.service.TransitVehicleRecordService;
|
|
|
|
import com.ssf.mysqloracletest.service.TransitVehicleRecordService;
|
|
|
|
import com.ssf.mysqloracletest.utils.ConfigParam;
|
|
|
|
import com.ssf.mysqloracletest.utils.ConfigParam;
|
|
|
|
import com.ssf.mysqloracletest.utils.StringKit;
|
|
|
|
import com.ssf.mysqloracletest.utils.StringKit;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
import org.checkerframework.checker.units.qual.C;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.TimeZone;
|
|
|
|
import java.util.TimeZone;
|
|
|
|
|
|
|
|
|
|
|
@ -30,7 +35,7 @@ public class TMotorvehicleTask {
|
|
|
|
private final TransitVehicleRecordService vehicleRecordService;
|
|
|
|
private final TransitVehicleRecordService vehicleRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
String maxTime = "20231223000000";
|
|
|
|
String maxTime = "20231225000000";
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
public void setVehicleRecordService() {
|
|
|
|
public void setVehicleRecordService() {
|
|
|
@ -40,14 +45,20 @@ public class TMotorvehicleTask {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
|
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
|
LambdaQueryWrapper<TMotorvehicle> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
LambdaQueryWrapper<TransitVehicleRecord> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
queryWrapper.gt(TMotorvehicle::getPasstime, maxTime);
|
|
|
|
queryWrapper.orderByDesc(TransitVehicleRecord::getPartitionField);
|
|
|
|
int countTM = tMotorvehicleService.count(queryWrapper);
|
|
|
|
queryWrapper.last("LIMIT 1");
|
|
|
|
|
|
|
|
TransitVehicleRecord one = vehicleRecordService.getOne(queryWrapper);
|
|
|
|
|
|
|
|
Date partitionField = one.getPartitionField();
|
|
|
|
|
|
|
|
maxTime = dateFormat.format(partitionField);
|
|
|
|
|
|
|
|
LambdaQueryWrapper<TMotorvehicle> Wrapper = Wrappers.lambdaQuery();
|
|
|
|
|
|
|
|
Wrapper.gt(TMotorvehicle::getPasstime, maxTime);
|
|
|
|
|
|
|
|
int countTM = tMotorvehicleService.count(Wrapper);
|
|
|
|
if (countTM > 0) {
|
|
|
|
if (countTM > 0) {
|
|
|
|
int count = countTM / 1000;
|
|
|
|
int count = countTM / 1000;
|
|
|
|
for (int i = 0; i <= count; i++) {
|
|
|
|
for (int i = 0; i <= count; i++) {
|
|
|
|
Page<TMotorvehicle> page = new Page<>(i + 1, 1000);
|
|
|
|
Page<TMotorvehicle> page = new Page<>(i + 1, 1000);
|
|
|
|
List<TMotorvehicle> resultList = tMotorvehicleService.page(page, queryWrapper).getRecords();
|
|
|
|
List<TMotorvehicle> resultList = tMotorvehicleService.page(page, Wrapper).getRecords();
|
|
|
|
for (TMotorvehicle Tmvehicle : resultList) {
|
|
|
|
for (TMotorvehicle Tmvehicle : resultList) {
|
|
|
|
TransitVehicleRecord vehicleRecord = new TransitVehicleRecord();
|
|
|
|
TransitVehicleRecord vehicleRecord = new TransitVehicleRecord();
|
|
|
|
vehicleRecord.setDoorwayCode(Tmvehicle.getTollgateid());
|
|
|
|
vehicleRecord.setDoorwayCode(Tmvehicle.getTollgateid());
|
|
|
@ -71,9 +82,9 @@ public class TMotorvehicleTask {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
UpdateWrapper<TransitVehicleRecord> wrapper = new UpdateWrapper<>();
|
|
|
|
UpdateWrapper<TransitVehicleRecord> wrapper = new UpdateWrapper<>();
|
|
|
|
wrapper.eq("global_pic",Tmvehicle.getStorageurl1());
|
|
|
|
wrapper.eq("global_pic", Tmvehicle.getStorageurl1());
|
|
|
|
boolean update = vehicleRecordService.update(vehicleRecord,wrapper);
|
|
|
|
boolean update = vehicleRecordService.update(vehicleRecord, wrapper);
|
|
|
|
if (update){
|
|
|
|
if (update) {
|
|
|
|
logger.info("Vehicle-" + Tmvehicle.getStorageurl1() + ":更新成功");
|
|
|
|
logger.info("Vehicle-" + Tmvehicle.getStorageurl1() + ":更新成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -86,4 +97,44 @@ public class TMotorvehicleTask {
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
|
|
|
|
public void DeleteOldVehicle() {
|
|
|
|
|
|
|
|
if (!"true".equals(ConfigParam.DeleteOldVehicleSwtich)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
|
|
|
|
|
LambdaQueryWrapper<TransitVehicleRecord> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
|
|
|
queryWrapper.orderByDesc(TransitVehicleRecord::getPartitionField);
|
|
|
|
|
|
|
|
queryWrapper.last("LIMIT 1");
|
|
|
|
|
|
|
|
TransitVehicleRecord one = vehicleRecordService.getOne(queryWrapper);
|
|
|
|
|
|
|
|
Date partitionField = one.getPartitionField();
|
|
|
|
|
|
|
|
maxTime = dateFormat.format(partitionField);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将maxTime转换为Date对象
|
|
|
|
|
|
|
|
Date maxDate = dateFormat.parse(maxTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计算7天前的日期
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
|
|
|
calendar.setTime(maxDate);
|
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH, -2);
|
|
|
|
|
|
|
|
Date twoDaysAgo = calendar.getTime();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//构造删除条件
|
|
|
|
|
|
|
|
LambdaQueryWrapper<TransitVehicleRecord> deleteWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
|
|
|
deleteWrapper.le(TransitVehicleRecord::getPartitionField, twoDaysAgo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean result = vehicleRecordService.remove(deleteWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
|
|
System.out.println("删除成功! ");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
System.out.println("删除失败! ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.info(StringKit.getTrace(e));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|