添加人流

develop
Angel 10 months ago
parent 64dd959b38
commit 247f57df97

@ -4,20 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ssf.mysqloracletest.domain.PeopleVehicleFlow;
import com.ssf.mysqloracletest.domain.TMotorvehicle;
import com.ssf.mysqloracletest.domain.TransitUserRecord;
import com.ssf.mysqloracletest.domain.TStrhEntityInfoKs;
import com.ssf.mysqloracletest.service.PeopleVehicleFlowService;
import com.ssf.mysqloracletest.service.TMotorvehicleService;
import com.ssf.mysqloracletest.service.TStrhEntityInfoKsService;
import com.ssf.mysqloracletest.utils.ConfigParam;
import com.ssf.mysqloracletest.utils.StringKit;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -57,20 +55,20 @@ public class PeopleVehicleFlowTask {
// 将日期部分格式化为数据库存储格式
String formattedDate = targetDate.format(formatter);
queryWrapper.between("passtime", formattedDate,targetDate.plusDays(1).format(formatter));
queryWrapper.between("passtime", formattedDate, targetDate.plusDays(1).format(formatter));
int count = tMotorvehicleService.count(queryWrapper);
PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow();
peopleVehicleFlow.setStatistic_count(String.valueOf(count));
peopleVehicleFlow.setStatistic_type(2);
peopleVehicleFlow.setStatistic_time(date.toString());
PeopleVehicleFlow one = peopleVehicleFlowService.lambdaQuery().eq(PeopleVehicleFlow::getStatistic_time, date.toString())
.eq(PeopleVehicleFlow::getStatistic_type ,2).one();
if (one == null){
.eq(PeopleVehicleFlow::getStatistic_type, 2).one();
if (one == null) {
boolean save = peopleVehicleFlowService.save(peopleVehicleFlow);
if (save) {
logger.info("Face-" + date + ":插入成功");
}
}else {
} else {
UpdateWrapper<PeopleVehicleFlow> wrapper = new UpdateWrapper<>();
wrapper.eq("statistic_time", date.toString());
wrapper.eq("statistic_type", 2);
@ -94,13 +92,14 @@ public class PeopleVehicleFlowTask {
}
try {
LocalDate localDate = LocalDate.now();
//获取当前日期
LocalDateTime localDate = LocalDateTime.now();
//循环迭代7天
for (int i = 0; i < 7; i++) {
//构造查询条件
QueryWrapper<TStrhEntityInfoKs> queryWrapper = new QueryWrapper<>();
// 减去 i 天并设置查询条件的日期字段
LocalDate date = localDate.minusDays(i);
LocalDateTime date = localDate.minusDays(i);
// 将日期部分格式化为数据库存储格式
String formattedDate = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
@ -109,7 +108,23 @@ public class PeopleVehicleFlowTask {
PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow();
peopleVehicleFlow.setStatistic_count(String.valueOf(count));
peopleVehicleFlow.setStatistic_type(1);
peopleVehicleFlow.setStatistic_time(localDate.toString());
peopleVehicleFlow.setStatistic_time(date.toString());
PeopleVehicleFlow one = peopleVehicleFlowService.lambdaQuery().eq(PeopleVehicleFlow::getStatistic_time, date.toString())
.eq(PeopleVehicleFlow::getStatistic_type, 1).one();
if (one == null) {
boolean save = peopleVehicleFlowService.save(peopleVehicleFlow);
if (save) {
logger.info("Face-" + date + ":插入成功");
}
} else {
UpdateWrapper<PeopleVehicleFlow> wrapper = new UpdateWrapper<>();
wrapper.eq("statistic_time", date.toString());
wrapper.eq("statistic_type", 2);
boolean update = peopleVehicleFlowService.update(peopleVehicleFlow, wrapper);
if (update) {
logger.info("Face-" + date + ":更新成功");
}
}
}
} catch (Exception e) {
logger.info(StringKit.getTrace(e));

Loading…
Cancel
Save