Commit d608897b by zhuht

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

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