Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	src/main/java/com/ssf/mysqloracletest/task/PeopleVehicleFlowTask.java
develop
Angel 10 months ago
commit 64dd959b38

@ -40,6 +40,11 @@
<version>2.5.4</version> <version>2.5.4</version>
</dependency> </dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>

@ -27,7 +27,7 @@ import java.util.List;
*/ */
@RequiredArgsConstructor @RequiredArgsConstructor
@Component //@Component
public class DevopsVideoInfoController { public class DevopsVideoInfoController {
private static final Logger logger = LoggerFactory.getLogger(DevopsVideoInfoController.class); private static final Logger logger = LoggerFactory.getLogger(DevopsVideoInfoController.class);
private final DevopsVideoInfoService0 devopsVideoInfoService; private final DevopsVideoInfoService0 devopsVideoInfoService;

@ -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<String, Object> 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<String, Object> getParams() {
if (params == null) {
params = new HashMap<>();
}
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
}

@ -1,6 +1,6 @@
package com.ssf.mysqloracletest.domain.vo; package com.ssf.mysqloracletest.domain.vo;
import com.ruoyi.common.core.domain.BaseEntity; import com.ssf.mysqloracletest.domain.BaseEntity;
import lombok.Data; import lombok.Data;
/** /**

@ -3,6 +3,7 @@ package com.ssf.mysqloracletest.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ssf.mysqloracletest.domain.DevopsVideoStatus; import com.ssf.mysqloracletest.domain.DevopsVideoStatus;
import lombok.AllArgsConstructor;
import java.util.List; import java.util.List;
@ -13,6 +14,7 @@ import java.util.List;
* @author makejava * @author makejava
* @since 2023-11-29 09:33:21 * @since 2023-11-29 09:33:21
*/ */
public interface DevopsVideoStatusService extends IService<DevopsVideoStatus> { public interface DevopsVideoStatusService extends IService<DevopsVideoStatus> {
/** /**

@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssf.mysqloracletest.domain.DevopsVideoInfo0; 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.NumKit;
import com.ssf.mysqloracletest.utils.PropertiesUtil; import com.ssf.mysqloracletest.utils.PropertiesUtil;
import com.ssf.mysqloracletest.utils.StringKit; import com.ssf.mysqloracletest.utils.StringKit;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -33,8 +35,10 @@ import java.util.List;
* @author makejava * @author makejava
* @since 2023-11-29 09:33:20 * @since 2023-11-29 09:33:20
*/ */
@Service //@Service
//@DS("mysql")
@RequiredArgsConstructor @RequiredArgsConstructor
public class DevopsVideoInfoServiceImpl extends ServiceImpl<DevopsVideoInfoMapper, DevopsVideoInfo0> implements DevopsVideoInfoService0 { public class DevopsVideoInfoServiceImpl extends ServiceImpl<DevopsVideoInfoMapper, DevopsVideoInfo0> implements DevopsVideoInfoService0 {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());

@ -1,21 +1,25 @@
package com.ssf.mysqloracletest.task; package com.ssf.mysqloracletest.task;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.PeopleVehicleFlow;
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.service.PeopleVehicleFlowService; import com.ssf.mysqloracletest.service.PeopleVehicleFlowService;
import com.ssf.mysqloracletest.service.TMotorvehicleService; import com.ssf.mysqloracletest.service.TMotorvehicleService;
import com.ssf.mysqloracletest.service.TStrhEntityInfoKsService; import com.ssf.mysqloracletest.service.TStrhEntityInfoKsService;
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.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 org.slf4j.Logger;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@Component @Component
@ -29,6 +33,9 @@ public class PeopleVehicleFlowTask {
//人车流量业表 //人车流量业表
private final PeopleVehicleFlowService peopleVehicleFlowService; private final PeopleVehicleFlowService peopleVehicleFlowService;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
@Scheduled(initialDelay = 100, fixedDelay = 3000) @Scheduled(initialDelay = 100, fixedDelay = 3000)
public void setVehicleFlowService() { public void setVehicleFlowService() {
if (!"true".equals(ConfigParam.vehicleFlowSwitch)) { if (!"true".equals(ConfigParam.vehicleFlowSwitch)) {
@ -37,24 +44,43 @@ public class PeopleVehicleFlowTask {
try { try {
//获取当前日期 //获取当前日期
LocalDateTime currentDate = LocalDateTime.now();//例如2023-10-10 00:00:00
LocalDateTime startOfDay = currentDate.withHour(0).withMinute(0).withSecond(0);
LocalDate localDate = LocalDate.now(); LocalDate localDate = LocalDate.now();
//循环迭代7天 //循环迭代7天
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
//构造查询条件 //构造查询条件
QueryWrapper<TMotorvehicle> queryWrapper = new QueryWrapper<>(); QueryWrapper<TMotorvehicle> queryWrapper = new QueryWrapper<>();
// 减去 i 天并设置查询条件的日期字段 // 减去 i 天并设置查询条件的日期字段
//LocalDateTime targetDate = currentDate.minusDays(i); LocalDateTime targetDate = startOfDay.minusDays(i);
LocalDate date = localDate.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); int count = tMotorvehicleService.count(queryWrapper);
PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow(); PeopleVehicleFlow peopleVehicleFlow = new PeopleVehicleFlow();
peopleVehicleFlow.setStatistic_count(String.valueOf(count)); peopleVehicleFlow.setStatistic_count(String.valueOf(count));
peopleVehicleFlow.setStatistic_type(2); peopleVehicleFlow.setStatistic_type(2);
peopleVehicleFlow.setStatistic_time(date.toString()); 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<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) { } catch (Exception e) {
logger.info(StringKit.getTrace(e)); logger.info(StringKit.getTrace(e));

@ -59,7 +59,7 @@ public class TMotorvehicleTask {
//计算2天后的日期 //计算2天后的日期
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(maxDate); calendar.setTime(maxDate);
calendar.add(Calendar.DAY_OF_MONTH, 2); calendar.add(Calendar.HOUR_OF_DAY, 12);
Date twoDaysAgo = calendar.getTime(); Date twoDaysAgo = calendar.getTime();
String format = dateFormat.format(twoDaysAgo); String format = dateFormat.format(twoDaysAgo);
LambdaQueryWrapper<TMotorvehicle> Wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<TMotorvehicle> Wrapper = Wrappers.lambdaQuery();
@ -67,11 +67,11 @@ public class TMotorvehicleTask {
Wrapper.le(TMotorvehicle::getPasstime, format); Wrapper.le(TMotorvehicle::getPasstime, format);
int countTM = tMotorvehicleService.count(Wrapper); int countTM = tMotorvehicleService.count(Wrapper);
if (countTM > 0) { if (countTM > 0) {
int count = countTM / 1000; // int count = countTM / 1000;
Page<TMotorvehicle> page = new Page<>( 1, 1000); // Page<TMotorvehicle> page = new Page<>( 1, 1000);
for (int i = 0; i <= count; i++) { // for (int i = 0; i <= count; i++) {
page.setCurrent(i + 1); // page.setCurrent(i + 1);
List<TMotorvehicle> resultList = tMotorvehicleService.page(page, Wrapper).getRecords(); List<TMotorvehicle> resultList = tMotorvehicleService.list(Wrapper);
for (TMotorvehicle Tmvehicle : resultList) { for (TMotorvehicle Tmvehicle : resultList) {
TransitVehicleRecord vehicleRecord = new TransitVehicleRecord(); TransitVehicleRecord vehicleRecord = new TransitVehicleRecord();
BoneVehicle one2 = boneVehicleService.lambdaQuery().eq(BoneVehicle::getNo, Tmvehicle.getPlateno()).one(); BoneVehicle one2 = boneVehicleService.lambdaQuery().eq(BoneVehicle::getNo, Tmvehicle.getPlateno()).one();
@ -107,7 +107,7 @@ public class TMotorvehicleTask {
} }
} }
} }
} // }
} }
} catch ( } catch (
Exception e Exception e

@ -68,7 +68,7 @@ public class TStrhEntityInfoKsTask {
//计算2天后的日期 //计算2天后的日期
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(maxDate); calendar.setTime(maxDate);
calendar.add(Calendar.DAY_OF_MONTH, 2); calendar.add(Calendar.HOUR_OF_DAY, 12);
Date twoDaysAgo = calendar.getTime(); Date twoDaysAgo = calendar.getTime();
@ -78,10 +78,10 @@ public class TStrhEntityInfoKsTask {
int countTStrh = tStrhEntityInfoKsService.count(Wrapper); int countTStrh = tStrhEntityInfoKsService.count(Wrapper);
if (countTStrh > 0) { if (countTStrh > 0) {
int count = countTStrh / 1000; // int count = countTStrh / 1000;
for (int i = 0; i <= count; i++) { // for (int i = 0; i <= count; i++) {
Page<TStrhEntityInfoKs> page = new Page<>(i + 1, 1000); // Page<TStrhEntityInfoKs> page = new Page<>(i + 1, 1000);
List<TStrhEntityInfoKs> resultList = tStrhEntityInfoKsService.page(page, Wrapper).getRecords(); List<TStrhEntityInfoKs> resultList = tStrhEntityInfoKsService.list(Wrapper);
for (TStrhEntityInfoKs entityInfoKs : resultList) { for (TStrhEntityInfoKs entityInfoKs : resultList) {
TransitUserRecord transitUserRecord = new TransitUserRecord(); TransitUserRecord transitUserRecord = new TransitUserRecord();
transitUserRecord.setDeviceCode(entityInfoKs.getCameraidx()); transitUserRecord.setDeviceCode(entityInfoKs.getCameraidx());
@ -110,7 +110,7 @@ public class TStrhEntityInfoKsTask {
} }
} }
} // }
} }
} catch ( } catch (
Exception e) { Exception e) {

@ -63,5 +63,7 @@ public class ConfigParam {
public static String DeleteOldSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("DeleteOldSwitch")); public static String DeleteOldSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("DeleteOldSwitch"));
public static String TMotorvehicleSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("TMotorvehicleSwitch")); public static String TMotorvehicleSwitch = StringKit.toString(PropertiesUtil.queryPropertiesByKey("TMotorvehicleSwitch"));
public static String DeleteOldVehicleSwtich = StringKit.toString(PropertiesUtil.queryPropertiesByKey("DeleteOldVehicleSwtich")); 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"));
} }

Loading…
Cancel
Save