parent
3149599e25
commit
0200a83f24
@ -0,0 +1,13 @@
|
||||
package com.ssf.mysqloracletest.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ssf.mysqloracletest.domain.TStrhEntityInfoKs;
|
||||
|
||||
|
||||
public interface TStrhEntityInfoKsMapper extends BaseMapper<TStrhEntityInfoKs> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.ssf.mysqloracletest.mapper;
|
||||
|
||||
import com.ssf.mysqloracletest.domain.TransitUserRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【transit_user_record(人脸记录表)】的数据库操作Mapper
|
||||
* @createDate 2023-12-22 10:29:24
|
||||
* @Entity com.ssf.mysqloracletest.domain.TransitUserRecord
|
||||
*/
|
||||
public interface TransitUserRecordMapper extends BaseMapper<TransitUserRecord> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.ssf.mysqloracletest.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ssf.mysqloracletest.domain.TStrhEntityInfoKs;
|
||||
|
||||
|
||||
public interface TStrhEntityInfoKsService extends IService<TStrhEntityInfoKs> {
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.ssf.mysqloracletest.service;
|
||||
|
||||
import com.ssf.mysqloracletest.domain.TransitUserRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【transit_user_record(人脸记录表)】的数据库操作Service
|
||||
* @createDate 2023-12-22 10:29:24
|
||||
*/
|
||||
public interface TransitUserRecordService extends IService<TransitUserRecord> {
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.ssf.mysqloracletest.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ssf.mysqloracletest.domain.TStrhEntityInfoKs;
|
||||
import com.ssf.mysqloracletest.mapper.TStrhEntityInfoKsMapper;
|
||||
import com.ssf.mysqloracletest.service.TStrhEntityInfoKsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@DS("postgre")
|
||||
public class TStrhEntityInfoKsServiceImpl extends ServiceImpl<TStrhEntityInfoKsMapper, TStrhEntityInfoKs>
|
||||
implements TStrhEntityInfoKsService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.ssf.mysqloracletest.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ssf.mysqloracletest.domain.TransitUserRecord;
|
||||
import com.ssf.mysqloracletest.service.TransitUserRecordService;
|
||||
import com.ssf.mysqloracletest.mapper.TransitUserRecordMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 10503
|
||||
* @description 针对表【transit_user_record(人脸记录表)】的数据库操作Service实现
|
||||
* @createDate 2023-12-22 10:29:24
|
||||
*/
|
||||
@Service
|
||||
public class TransitUserRecordServiceImpl extends ServiceImpl<TransitUserRecordMapper, TransitUserRecord>
|
||||
implements TransitUserRecordService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,108 @@
|
||||
package com.ssf.mysqloracletest.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ssf.mysqloracletest.domain.TStrhEntityInfoKs;
|
||||
import com.ssf.mysqloracletest.domain.TransitUserRecord;
|
||||
import com.ssf.mysqloracletest.service.TStrhEntityInfoKsService;
|
||||
import com.ssf.mysqloracletest.service.TransitUserRecordService;
|
||||
import com.ssf.mysqloracletest.utils.ConfigParam;
|
||||
import com.ssf.mysqloracletest.utils.NumKit;
|
||||
import com.ssf.mysqloracletest.utils.StringKit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
|
||||
/**
|
||||
* 人员轨迹数据接入
|
||||
*/
|
||||
@Component
|
||||
public class TStrhEntityInfoKsTask {
|
||||
private static final Logger logger = LoggerFactory.getLogger(TStrhEntityInfoKsTask.class);
|
||||
|
||||
@Resource
|
||||
private TStrhEntityInfoKsService tStrhEntityInfoKsService;
|
||||
|
||||
@Resource
|
||||
private TransitUserRecordService transitUserRecordService;
|
||||
|
||||
final int oncesCounts = NumKit.checkInt(ConfigParam.oncesCounts) == 0 ? 1000 : NumKit.checkInt(ConfigParam.oncesCounts);
|
||||
|
||||
String maxTime = "2023-10-01 00:00:00";
|
||||
|
||||
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
||||
public void setTransitUserRecordService() {
|
||||
if (!"true".equals(ConfigParam.TStrhEntityInfoSwitch)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
int countTStrh = tStrhEntityInfoKsService.count();
|
||||
|
||||
if (countTStrh > 0) {
|
||||
|
||||
int count = countTStrh / oncesCounts;
|
||||
CountDownLatch latch = new CountDownLatch(countTStrh);
|
||||
|
||||
for (int i = 0; i <= count; i++) {
|
||||
try {
|
||||
QueryWrapper<TStrhEntityInfoKs> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.ge("captureTime", maxTime);
|
||||
Page<TStrhEntityInfoKs> page = new Page<>(i + 1, 1000);
|
||||
List<TStrhEntityInfoKs> resultList = tStrhEntityInfoKsService.page(page, queryWrapper).getRecords();
|
||||
for (TStrhEntityInfoKs entityInfoKs : resultList) {
|
||||
TransitUserRecord transitUserRecord = new TransitUserRecord();
|
||||
transitUserRecord.setDeviceCode(entityInfoKs.getCameraidx());
|
||||
transitUserRecord.setPassTime(Long.parseLong(entityInfoKs.getCapturetime()));
|
||||
transitUserRecord.setBodyGlobalPic(entityInfoKs.getImage());
|
||||
transitUserRecord.setPersonPic(entityInfoKs.getSmalimage());
|
||||
transitUserRecord.setSourceId(entityInfoKs.getEntityid());
|
||||
transitUserRecord.setIdCard(entityInfoKs.getIdentityid());
|
||||
transitUserRecord.setUserName(entityInfoKs.getName());
|
||||
//确定一个数据是否唯一
|
||||
TransitUserRecord one = transitUserRecordService.lambdaQuery().eq(TransitUserRecord::getPersonPic, entityInfoKs.getSmalimage()).one();
|
||||
if (one == null) {
|
||||
boolean save = transitUserRecordService.save(transitUserRecord);
|
||||
if (save) {
|
||||
logger.info("Face-" + entityInfoKs.getSmalimage() + ":插入成功");
|
||||
}
|
||||
}else {
|
||||
UpdateWrapper<TransitUserRecord> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("person_pic", entityInfoKs.getSmalimage());
|
||||
boolean update = transitUserRecordService.update(transitUserRecord,wrapper);
|
||||
if (update){
|
||||
logger.info("Face-" + entityInfoKs.getSmalimage() + ":更新成功");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("TSInfos:" + StringKit.getTrace(e));
|
||||
}
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
try {
|
||||
// Wait for all threads to complete
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info(StringKit.getTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue