From 406eda2b8e9a751f0668c0745b9826fd6eadce6c Mon Sep 17 00:00:00 2001 From: hanrenchun Date: Wed, 3 Jan 2024 14:48:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E8=BD=A6=E6=8A=93=E6=8B=8D=E6=9B=B4?= =?UTF-8?q?=E6=96=B0,=E4=BA=BA=E8=BD=A6=E6=B5=81=E9=87=8F=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 + .../Controller/DevopsVideoInfoController.java | 2 +- .../mysqloracletest/domain/BaseEntity.java | 133 ++++++++++++++++++ .../domain/vo/DevopsVideoInfoVo.java | 2 +- .../service/DevopsVideoStatusService.java | 2 + .../impl/DevopsVideoInfoServiceImpl.java | 6 +- .../task/PeopleVehicleFlowTask.java | 35 ++++- .../task/TMotorvehicleTask.java | 14 +- .../task/TStrhEntityInfoKsTask.java | 12 +- .../mysqloracletest/utils/ConfigParam.java | 2 + 10 files changed, 191 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/ssf/mysqloracletest/domain/BaseEntity.java diff --git a/pom.xml b/pom.xml index ae04339..31aac5e 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,11 @@ 2.5.4 + + org.jsoup + jsoup + 1.9.2 + mysql mysql-connector-java diff --git a/src/main/java/com/ssf/mysqloracletest/Controller/DevopsVideoInfoController.java b/src/main/java/com/ssf/mysqloracletest/Controller/DevopsVideoInfoController.java index aef6ea9..61df115 100644 --- a/src/main/java/com/ssf/mysqloracletest/Controller/DevopsVideoInfoController.java +++ b/src/main/java/com/ssf/mysqloracletest/Controller/DevopsVideoInfoController.java @@ -27,7 +27,7 @@ import java.util.List; */ @RequiredArgsConstructor -@Component +//@Component public class DevopsVideoInfoController { private static final Logger logger = LoggerFactory.getLogger(DevopsVideoInfoController.class); private final DevopsVideoInfoService0 devopsVideoInfoService; diff --git a/src/main/java/com/ssf/mysqloracletest/domain/BaseEntity.java b/src/main/java/com/ssf/mysqloracletest/domain/BaseEntity.java new file mode 100644 index 0000000..cb756f1 --- /dev/null +++ b/src/main/java/com/ssf/mysqloracletest/domain/BaseEntity.java @@ -0,0 +1,133 @@ +package com.ssf.mysqloracletest.domain; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * Entity基类 + * + * @author ruoyi + */ +public class BaseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** 搜索值 */ + @JsonIgnore + @TableField(exist = false) + private String searchValue; + + /** 创建者 */ + private String createBy; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 更新者 */ + private String updateBy; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** 备注 */ + @TableField(exist = false) + private String remark; + + /** 请求参数 */ + @TableField(exist = false) + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private Map params; + + @TableField(exist = false) + private String firstTime; + + @TableField(exist = false) + private String endTime; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getFirstTime() { + return firstTime; + } + + public void setFirstTime(String firstTime) { + this.firstTime = firstTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getSearchValue() { + return searchValue; + } + + public void setSearchValue(String searchValue) { + this.searchValue = searchValue; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Map getParams() { + if (params == null) { + params = new HashMap<>(); + } + return params; + } + + public void setParams(Map params) { + this.params = params; + } +} diff --git a/src/main/java/com/ssf/mysqloracletest/domain/vo/DevopsVideoInfoVo.java b/src/main/java/com/ssf/mysqloracletest/domain/vo/DevopsVideoInfoVo.java index 0030fbc..e9decac 100644 --- a/src/main/java/com/ssf/mysqloracletest/domain/vo/DevopsVideoInfoVo.java +++ b/src/main/java/com/ssf/mysqloracletest/domain/vo/DevopsVideoInfoVo.java @@ -1,6 +1,6 @@ package com.ssf.mysqloracletest.domain.vo; -import com.ruoyi.common.core.domain.BaseEntity; +import com.ssf.mysqloracletest.domain.BaseEntity; import lombok.Data; /** diff --git a/src/main/java/com/ssf/mysqloracletest/service/DevopsVideoStatusService.java b/src/main/java/com/ssf/mysqloracletest/service/DevopsVideoStatusService.java index bec7d25..b69605b 100644 --- a/src/main/java/com/ssf/mysqloracletest/service/DevopsVideoStatusService.java +++ b/src/main/java/com/ssf/mysqloracletest/service/DevopsVideoStatusService.java @@ -3,6 +3,7 @@ package com.ssf.mysqloracletest.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ssf.mysqloracletest.domain.DevopsVideoStatus; +import lombok.AllArgsConstructor; import java.util.List; @@ -13,6 +14,7 @@ import java.util.List; * @author makejava * @since 2023-11-29 09:33:21 */ + public interface DevopsVideoStatusService extends IService { /** diff --git a/src/main/java/com/ssf/mysqloracletest/service/impl/DevopsVideoInfoServiceImpl.java b/src/main/java/com/ssf/mysqloracletest/service/impl/DevopsVideoInfoServiceImpl.java index 9824b3c..bb7e16c 100644 --- a/src/main/java/com/ssf/mysqloracletest/service/impl/DevopsVideoInfoServiceImpl.java +++ b/src/main/java/com/ssf/mysqloracletest/service/impl/DevopsVideoInfoServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ssf.mysqloracletest.domain.DevopsVideoInfo0; @@ -19,6 +20,7 @@ import com.ssf.mysqloracletest.utils.JsoupUtils; import com.ssf.mysqloracletest.utils.NumKit; import com.ssf.mysqloracletest.utils.PropertiesUtil; import com.ssf.mysqloracletest.utils.StringKit; +import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,8 +35,10 @@ import java.util.List; * @author makejava * @since 2023-11-29 09:33:20 */ -@Service +//@Service +//@DS("mysql") @RequiredArgsConstructor + public class DevopsVideoInfoServiceImpl extends ServiceImpl implements DevopsVideoInfoService0 { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleFlowTask.java b/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleFlowTask.java index 2a658c4..83597a3 100644 --- a/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleFlowTask.java +++ b/src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleFlowTask.java @@ -1,8 +1,10 @@ package com.ssf.mysqloracletest.task; 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.service.PeopleVehicleFlowService; import com.ssf.mysqloracletest.service.TMotorvehicleService; import com.ssf.mysqloracletest.service.TStrhEntityInfoKsService; @@ -15,6 +17,7 @@ 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; @@ -30,6 +33,9 @@ public class PeopleVehicleFlowTask { //人车流量业表 private final PeopleVehicleFlowService peopleVehicleFlowService; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + + @Scheduled(initialDelay = 100, fixedDelay = 3000) public void setVehicleFlowService() { if (!"true".equals(ConfigParam.vehicleFlowSwitch)) { @@ -38,26 +44,43 @@ public class PeopleVehicleFlowTask { try { //获取当前日期 -// LocalDateTime currentDate = LocalDateTime.now();//例如:2023-10-10 00:00:00 -// LocalDateTime startOfDay = currentDate.withHour(0).withMinute(0).withSecond(0); + LocalDateTime currentDate = LocalDateTime.now();//例如:2023-10-10 00:00:00 + LocalDateTime startOfDay = currentDate.withHour(0).withMinute(0).withSecond(0); LocalDate localDate = LocalDate.now(); //循环迭代7天 for (int i = 0; i < 7; i++) { //构造查询条件 QueryWrapper queryWrapper = new QueryWrapper<>(); // 减去 i 天并设置查询条件的日期字段 -// LocalDateTime targetDate = currentDate.minusDays(i); + LocalDateTime targetDate = startOfDay.minusDays(i); LocalDate date = localDate.minusDays(i); // 将日期部分格式化为数据库存储格式 - String formattedDate = date.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); + String formattedDate = targetDate.format(formatter); - queryWrapper.between("passtime", formattedDate,date.plusDays(1).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); + 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()); - peopleVehicleFlowService.save(peopleVehicleFlow); + PeopleVehicleFlow one = peopleVehicleFlowService.lambdaQuery().eq(PeopleVehicleFlow::getStatistic_time, date.toString()) + .eq(PeopleVehicleFlow::getStatistic_type ,2).one(); + if (one == null){ + boolean save = peopleVehicleFlowService.save(peopleVehicleFlow); + if (save) { + logger.info("Face-" + date + ":插入成功"); + } + }else { + UpdateWrapper 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)); diff --git a/src/main/java/com/ssf/mysqloracletest/task/TMotorvehicleTask.java b/src/main/java/com/ssf/mysqloracletest/task/TMotorvehicleTask.java index 1be97ec..27c0460 100644 --- a/src/main/java/com/ssf/mysqloracletest/task/TMotorvehicleTask.java +++ b/src/main/java/com/ssf/mysqloracletest/task/TMotorvehicleTask.java @@ -59,7 +59,7 @@ public class TMotorvehicleTask { //计算2天后的日期 Calendar calendar = Calendar.getInstance(); calendar.setTime(maxDate); - calendar.add(Calendar.DAY_OF_MONTH, 2); + calendar.add(Calendar.HOUR_OF_DAY, 12); Date twoDaysAgo = calendar.getTime(); String format = dateFormat.format(twoDaysAgo); LambdaQueryWrapper Wrapper = Wrappers.lambdaQuery(); @@ -67,11 +67,11 @@ public class TMotorvehicleTask { Wrapper.le(TMotorvehicle::getPasstime, format); int countTM = tMotorvehicleService.count(Wrapper); if (countTM > 0) { - int count = countTM / 1000; - Page page = new Page<>( 1, 1000); - for (int i = 0; i <= count; i++) { - page.setCurrent(i + 1); - List resultList = tMotorvehicleService.page(page, Wrapper).getRecords(); +// int count = countTM / 1000; +// Page page = new Page<>( 1, 1000); +// for (int i = 0; i <= count; i++) { +// page.setCurrent(i + 1); + List resultList = tMotorvehicleService.list(Wrapper); for (TMotorvehicle Tmvehicle : resultList) { TransitVehicleRecord vehicleRecord = new TransitVehicleRecord(); BoneVehicle one2 = boneVehicleService.lambdaQuery().eq(BoneVehicle::getNo, Tmvehicle.getPlateno()).one(); @@ -107,7 +107,7 @@ public class TMotorvehicleTask { } } } - } +// } } } catch ( Exception e diff --git a/src/main/java/com/ssf/mysqloracletest/task/TStrhEntityInfoKsTask.java b/src/main/java/com/ssf/mysqloracletest/task/TStrhEntityInfoKsTask.java index 08bedb7..ea24ee2 100644 --- a/src/main/java/com/ssf/mysqloracletest/task/TStrhEntityInfoKsTask.java +++ b/src/main/java/com/ssf/mysqloracletest/task/TStrhEntityInfoKsTask.java @@ -68,7 +68,7 @@ public class TStrhEntityInfoKsTask { //计算2天后的日期 Calendar calendar = Calendar.getInstance(); calendar.setTime(maxDate); - calendar.add(Calendar.DAY_OF_MONTH, 2); + calendar.add(Calendar.HOUR_OF_DAY, 12); Date twoDaysAgo = calendar.getTime(); @@ -78,10 +78,10 @@ public class TStrhEntityInfoKsTask { int countTStrh = tStrhEntityInfoKsService.count(Wrapper); if (countTStrh > 0) { - int count = countTStrh / 1000; - for (int i = 0; i <= count; i++) { - Page page = new Page<>(i + 1, 1000); - List resultList = tStrhEntityInfoKsService.page(page, Wrapper).getRecords(); +// int count = countTStrh / 1000; +// for (int i = 0; i <= count; i++) { +// Page page = new Page<>(i + 1, 1000); + List resultList = tStrhEntityInfoKsService.list(Wrapper); for (TStrhEntityInfoKs entityInfoKs : resultList) { TransitUserRecord transitUserRecord = new TransitUserRecord(); transitUserRecord.setDeviceCode(entityInfoKs.getCameraidx()); @@ -110,7 +110,7 @@ public class TStrhEntityInfoKsTask { } } - } +// } } } catch ( Exception e) { diff --git a/src/main/java/com/ssf/mysqloracletest/utils/ConfigParam.java b/src/main/java/com/ssf/mysqloracletest/utils/ConfigParam.java index 822e4cb..09da75d 100644 --- a/src/main/java/com/ssf/mysqloracletest/utils/ConfigParam.java +++ b/src/main/java/com/ssf/mysqloracletest/utils/ConfigParam.java @@ -63,5 +63,7 @@ public class ConfigParam { public static String DeleteOldSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("DeleteOldSwitch")); public static String TMotorvehicleSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("TMotorvehicleSwitch")); public static String DeleteOldVehicleSwtich = StringKit.toString(PropertiesUtil.queryPropertiesByKey("DeleteOldVehicleSwtich")); + public static String DevopeVideoInfoSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("DevopeVideoInfoSwitch")); + public static String vehicleFlowSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("vehicleFlowSwitch")); }