人车当日修改

develop
hanrenchun 10 months ago
parent edceb73517
commit a3bd93932d

@ -31,7 +31,7 @@ public class PeopleVehicleHourFlowTask {
//人车流量业表 //人车流量业表
private final PeopleVehicleHourFlowService peopleVehicleHourFlowService; private final PeopleVehicleHourFlowService peopleVehicleHourFlowService;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
@Scheduled(initialDelay = 100, fixedDelay = 3000) @Scheduled(initialDelay = 100, fixedDelay = 3000)
public void setVehicleHourFlowService() { public void setVehicleHourFlowService() {
@ -50,19 +50,20 @@ public class PeopleVehicleHourFlowTask {
for (int i = 0; i < 24; i++) { for (int i = 0; i < 24; i++) {
//构造查询条件 //构造查询条件
QueryWrapper<TMotorvehicle> queryWrapper = new QueryWrapper<>(); QueryWrapper<TMotorvehicle> queryWrapper = new QueryWrapper<>();
//减去i小时 //i小时
LocalDateTime targetHour = startOfDay.minusHours(i); LocalDateTime targetHour = startOfDay.plusHours(i);
LocalDateTime time = Hour.minusHours(i); LocalDateTime time = Hour.plusHours(i + 1);
//将日期部分格式化为数据库存储格式 //将日期部分格式化为数据库存储格式
String formattedDate = targetHour.format(formatter); String formattedDate = targetHour.format(formatter);
String format = time.format(formatter1);
queryWrapper.between("passtime",formattedDate,targetHour.plusHours(1).format(formatter)); queryWrapper.between("passtime", formattedDate, targetHour.plusHours(i + 1).format(formatter));
int count = tMotorvehicleService.count(queryWrapper); int count = tMotorvehicleService.count(queryWrapper);
PeopleVehicleHourFlow peopleVehicleHourFlow = new PeopleVehicleHourFlow(); PeopleVehicleHourFlow peopleVehicleHourFlow = new PeopleVehicleHourFlow();
peopleVehicleHourFlow.setStatistic_count(String.valueOf(count)); peopleVehicleHourFlow.setStatistic_count(String.valueOf(count));
peopleVehicleHourFlow.setStatistic_type(2); peopleVehicleHourFlow.setStatistic_type(2);
peopleVehicleHourFlow.setStatistic_time(time.toString()); peopleVehicleHourFlow.setStatistic_time(format);
PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, time.toString()) PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, format)
.eq(PeopleVehicleHourFlow::getStatistic_type, 2).one(); .eq(PeopleVehicleHourFlow::getStatistic_type, 2).one();
if (one == null) { if (one == null) {
boolean save = peopleVehicleHourFlowService.save(peopleVehicleHourFlow); boolean save = peopleVehicleHourFlowService.save(peopleVehicleHourFlow);
@ -108,14 +109,14 @@ public class PeopleVehicleHourFlowTask {
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDate = targetHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); String formattedDate = targetHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
queryWrapper.between("capturetime",formattedDate,targetHour.plusHours(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); queryWrapper.between("capturetime", formattedDate, targetHour.plusHours(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
int count = tStrhEntityInfoKsService.count(queryWrapper); int count = tStrhEntityInfoKsService.count(queryWrapper);
PeopleVehicleHourFlow peopleVehicleHourFlow = new PeopleVehicleHourFlow(); PeopleVehicleHourFlow peopleVehicleHourFlow = new PeopleVehicleHourFlow();
peopleVehicleHourFlow.setStatistic_count(String.valueOf(count)); peopleVehicleHourFlow.setStatistic_count(String.valueOf(count));
peopleVehicleHourFlow.setStatistic_type(2); peopleVehicleHourFlow.setStatistic_type(1);
peopleVehicleHourFlow.setStatistic_time(time.toString()); peopleVehicleHourFlow.setStatistic_time(time.toString());
PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, time.toString()) PeopleVehicleHourFlow one = peopleVehicleHourFlowService.lambdaQuery().eq(PeopleVehicleHourFlow::getStatistic_time, time.toString())
.eq(PeopleVehicleHourFlow::getStatistic_type, 2).one(); .eq(PeopleVehicleHourFlow::getStatistic_type, 1).one();
if (one == null) { if (one == null) {
boolean save = peopleVehicleHourFlowService.save(peopleVehicleHourFlow); boolean save = peopleVehicleHourFlowService.save(peopleVehicleHourFlow);
if (save) { if (save) {
@ -124,7 +125,7 @@ public class PeopleVehicleHourFlowTask {
} else { } else {
UpdateWrapper<PeopleVehicleHourFlow> wrapper = new UpdateWrapper<>(); UpdateWrapper<PeopleVehicleHourFlow> wrapper = new UpdateWrapper<>();
wrapper.eq("statistic_time", time.toString()); wrapper.eq("statistic_time", time.toString());
wrapper.eq("statistic_type", 2); wrapper.eq("statistic_type", 1);
boolean update = peopleVehicleHourFlowService.update(peopleVehicleHourFlow, wrapper); boolean update = peopleVehicleHourFlowService.update(peopleVehicleHourFlow, wrapper);
if (update) { if (update) {
logger.info("Face-" + time + ":更新成功"); logger.info("Face-" + time + ":更新成功");

Loading…
Cancel
Save