Commit d608897b by zhuht

[chg]过滤看车顾客增加严格模式;

1 parent 654dc5e5
......@@ -4,15 +4,10 @@ import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.viontech.keliu.dao.BGateDao;
import com.viontech.keliu.dao.ConfigParamDao;
import com.viontech.keliu.dao.DPersonBatchDao;
import com.viontech.keliu.dao.DPersonReceptionDao;
import com.viontech.keliu.dao.DPersonRecordDao;
import com.viontech.keliu.dao.DPersonTrackDetailDao;
import com.viontech.keliu.dao.FaceRecognitionDao;
import com.viontech.keliu.dao.*;
import com.viontech.keliu.entity.*;
import com.viontech.keliu.service.PersonRecordService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -25,16 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -75,6 +61,16 @@ public class PersonRecordServiceImpl implements PersonRecordService {
@Value("${reid.person.batch.mall:}")
private List<Long> personBatchMallIds;
/**
* 需要严格模式的门店
*/
@Value("${strictModeMallIds:}")
private List<Long> strictModeMallIds;
/**
* 严格模式的有效看车秒数
*/
@Value("${strictModeAttentionSecond:}")
private Integer strictModeAttentionSecond;
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
......@@ -89,6 +85,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
if (CollectionUtils.isEmpty(personList)) {
return;
}
boolean strictMode = strictModeMallIds != null && strictModeMallIds.contains(mallId);
Long excludePersonTime = getExcludePersonTime(mallId);
Integer filterAttention = getFilterAttention(mallId);
......@@ -106,7 +103,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
if (i == indexes.length - 1) {
persons = value.subList(indexes[i], value.size());
} else {
persons = value.subList(indexes[i],indexes[i+1]);
persons = value.subList(indexes[i], indexes[i + 1]);
}
List<Person> inSidePersonList = new ArrayList<>();
Person inPerson = null;
......@@ -120,7 +117,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
//店内
inSidePersonList.add(person);
} else if (person.getDirection() == -1 && gateIds.contains(person.getGateId())){
} else if (person.getDirection() == -1 && gateIds.contains(person.getGateId())) {
//离店
outPerson = person;
}
......@@ -217,9 +214,31 @@ public class PersonRecordServiceImpl implements PersonRecordService {
if (dPersonRecord.getVisitDuration() < excludePersonTime * 60 * 1000) {
continue;
}
//没有被接待,并且没有看车的排除掉
if (dPersonRecord.getReceptionCount() == 0 && filterAttention == 1 && dPersonRecord.getAttentionCount() == 0) {
continue;
if (strictMode) {
log.info("门店:{}严格模式过滤", mallId);
// 严格模式,没接待,或没看车,就过滤
if (filterAttention == 1) {
if (dPersonRecord.getReceptionCount() == 0) {
continue;
}
List<DPersonTrackDetail> personTrackDetailList = dPersonRecord.getPersonTrackDetailList();
if (CollectionUtils.isEmpty(personTrackDetailList)) {
continue;
}
List<DPersonTrackDetail> attentionList = personTrackDetailList.stream().filter(v -> v.getVisitDuration() != null && v.getVisitDuration() > strictModeAttentionSecond * 1000L)
.sorted(Comparator.comparing(DPersonTrackDetail::getArriveTime)).toList();
if (attentionList.isEmpty()) {
continue;
}
dPersonRecord.setAttentionCount(attentionList.size());
dPersonRecord.setAttentionTime(attentionList.get(0).getArriveTime());
}
} else {
//没有被接待,并且没有看车的排除掉
if (dPersonRecord.getReceptionCount() == 0 && filterAttention == 1 && dPersonRecord.getAttentionCount() == 0) {
continue;
}
}
personRecordList.add(dPersonRecord);
dPersonRecordDao.createDPersonRecordBatch(Collections.singletonList(dPersonRecord));
......@@ -245,6 +264,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
/**
* 分组
*
* @param personList
* @return
*/
......@@ -309,6 +329,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
/**
* 处理顾客区域数据,接待,看车,试乘
*
* @param personInOutDetailList
* @return
*/
......@@ -391,11 +412,9 @@ public class PersonRecordServiceImpl implements PersonRecordService {
return dPersonRecordList;
}
private List<DPersonTrackDetail> getPersonTrackDetail(String groupUnid, List<Person> personList) {
if (personList.size() < 2) {
return null;
......@@ -501,9 +520,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
private void updateFaceRecognitionSta(Long mallId, Date countDate, List<DPersonRecord> personRecords) {
private void updateFaceRecognitionSta(Long mallId, Date countDate, List<DPersonRecord> personRecords) {
Map<String, DPersonRecord> personRecordMap = personRecords.stream().collect(Collectors.toMap(DPersonRecord::getPersonUnid, dPersonRecord -> dPersonRecord, (k1, k2) -> k1));
//顾客总人数
long customerCount = personRecordMap.keySet().size();
......@@ -535,14 +552,14 @@ public class PersonRecordServiceImpl implements PersonRecordService {
String[] maleStageArry = maleStage.split(",");
long[] maleStages = strArry2LongArry(maleStageArry);
maleStageMap.forEach((k,v) -> {
maleStageMap.forEach((k, v) -> {
maleStages[k] = v;
});
String[] femaleStageArry = femaleStage.split(",");
long[] femaleStages = strArry2LongArry(femaleStageArry);
femaleStageMap.forEach((k,v) -> {
femaleStageMap.forEach((k, v) -> {
femaleStages[k] = v;
});
String maleStageStr = arraysToString(maleStages);
......@@ -552,7 +569,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
CustomerGroupResult customerGroupResult = new CustomerGroupResult();
Map<String, List<DPersonRecord>> groupMap = personRecordMap.values().stream().collect(Collectors.groupingBy(DPersonRecord::getGroupUnid));
groupMap.forEach((k,v) -> {
groupMap.forEach((k, v) -> {
calGroup(1, customerGroupResult, v);
});
updateSta.setGroupNum(customerGroupResult.getGroupNum());
......@@ -569,10 +586,10 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
private void updateFaceRecognitionStaHour(Long mallId, Date countDate, List<DPersonRecord> personRecords) {
private void updateFaceRecognitionStaHour(Long mallId, Date countDate, List<DPersonRecord> personRecords) {
Map<String, List<DPersonRecord>> personUnidMap = personRecords.stream().collect(Collectors.groupingBy(DPersonRecord::getPersonUnid));
List<DPersonRecord> personList = new ArrayList<>();
personUnidMap.forEach((k,v) -> {
personUnidMap.forEach((k, v) -> {
DPersonRecord dPersonRecord = v.stream().sorted(Comparator.comparing(DPersonRecord::getArriveTime)).findFirst().get();
personList.add(dPersonRecord);
});
......@@ -582,7 +599,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
List<DMallHourFaceRecognitionSta> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(DMallHourFaceRecognitionSta.class), mallId, countDate);
Map<String, DMallHourFaceRecognitionSta> hourStaMap = list.stream().collect(Collectors.toMap(d -> DateUtil.format(d.getCounttime(), "yyyy-MM-dd HH:00:00"), Function.identity(), (v1, v2) -> v1));
List<DMallHourFaceRecognitionSta> updateList = new ArrayList<>();
hourStaMap.forEach((k,v) -> {
hourStaMap.forEach((k, v) -> {
List<DPersonRecord> dPersonRecords = hourMap.get(k);
long customerCount = 0L;
long maleCount = 0L;
......@@ -615,13 +632,13 @@ public class PersonRecordServiceImpl implements PersonRecordService {
updateSta.setFemaleCount(femaleCount);
updateSta.setCounttime(DateUtil.parse(k, "yyyy-MM-dd HH:00:00"));
long[] maleStages = new long[100];
maleStageMap.forEach((k1,v1) -> {
maleStageMap.forEach((k1, v1) -> {
maleStages[k1] = v1;
});
long[] femaleStages = new long[100];
femaleStageMap.forEach((k1,v1) -> {
femaleStageMap.forEach((k1, v1) -> {
femaleStages[k1] = v1;
});
String maleStageStr = arraysToString(maleStages);
......@@ -632,7 +649,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
CustomerGroupResult customerGroupResult = new CustomerGroupResult();
if (!CollectionUtils.isEmpty(dPersonRecords)) {
Map<String, List<DPersonRecord>> groupMap = dPersonRecords.stream().collect(Collectors.groupingBy(DPersonRecord::getGroupUnid));
groupMap.forEach((k1,v1) -> {
groupMap.forEach((k1, v1) -> {
calGroup(1, customerGroupResult, v1);
});
}
......@@ -653,7 +670,6 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
}
private void updateMallDayResidenceCountData(Long mallId, Date countDate, List<DPersonRecord> personRecords) {
......@@ -701,8 +717,6 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
public String arraysToString(long[] arrays) {
return Arrays.toString(arrays).substring(1, Arrays.toString(arrays).length() - 1);
}
......@@ -717,7 +731,6 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
public void calGroup(int add, CustomerGroupResult result, List<DPersonRecord> records) {
if (CollectionUtils.isEmpty(records)) {
return;
......@@ -745,7 +758,4 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!