|
@@ -4,16 +4,16 @@ import com.alibaba.druid.sql.visitor.functions.Concat;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fdkankan.ucenter.entity.SceneCooperationCount;
|
|
|
+import com.fdkankan.ucenter.entity.User;
|
|
|
import com.fdkankan.ucenter.mapper.ISceneCooperationCountMapper;
|
|
|
import com.fdkankan.ucenter.service.ISceneCooperationCountService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.ucenter.service.ISceneCooperationService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -27,11 +27,21 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class SceneCooperationCountServiceImpl extends ServiceImpl<ISceneCooperationCountMapper, SceneCooperationCount> implements ISceneCooperationCountService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ISceneCooperationService sceneCooperationService;
|
|
|
@Override
|
|
|
- public void saveCount(List<String> numList, Integer size,String sceneType) {
|
|
|
- if(numList == null || numList.isEmpty() || size <=1){
|
|
|
+ public void saveCount(List<String> numList, Integer size,String sceneType,String type) {
|
|
|
+ if(numList == null || numList.isEmpty() || size <=0){
|
|
|
return;
|
|
|
}
|
|
|
+ if("scene".equals(type) && size<=1){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ HashMap<String, List<User>> userMap = new HashMap<>();
|
|
|
+ if("camera".equals(type)){
|
|
|
+ userMap = sceneCooperationService.getByNumList(numList, sceneType);
|
|
|
+ }
|
|
|
+
|
|
|
List<SceneCooperationCount> sceneCooperationCounts = this.getByNumList(numList,sceneType);
|
|
|
Set<String> dbNumList = sceneCooperationCounts.stream().map(SceneCooperationCount::getNum).collect(Collectors.toSet());
|
|
|
Set<String> addNumList = new HashSet<>(numList);
|
|
@@ -39,10 +49,11 @@ public class SceneCooperationCountServiceImpl extends ServiceImpl<ISceneCooperat
|
|
|
List<SceneCooperationCount> saveList = new ArrayList<>();
|
|
|
for (String num : addNumList) {
|
|
|
if(!dbNumList.contains(num)){
|
|
|
+ List<User> users = userMap.get(num);
|
|
|
SceneCooperationCount count = new SceneCooperationCount();
|
|
|
count.setSceneType(sceneType);
|
|
|
count.setNum(num);
|
|
|
- count.setCount(size);
|
|
|
+ count.setCount(users.size() + size);
|
|
|
saveList.add(count);
|
|
|
}
|
|
|
}
|
|
@@ -50,18 +61,15 @@ public class SceneCooperationCountServiceImpl extends ServiceImpl<ISceneCooperat
|
|
|
this.saveBatch(saveList);
|
|
|
}
|
|
|
|
|
|
- Set<Integer> updateList = new HashSet<>();
|
|
|
for (SceneCooperationCount sceneCooperationCount : sceneCooperationCounts) {
|
|
|
- if(sceneCooperationCount.getCount() < size){
|
|
|
- updateList.add(sceneCooperationCount.getId());
|
|
|
+ List<User> users = userMap.get(sceneCooperationCount.getNum());
|
|
|
+ if(sceneCooperationCount.getCount() < users.size() + size){
|
|
|
+ LambdaUpdateWrapper<SceneCooperationCount> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(SceneCooperationCount::getId,sceneCooperationCount.getId());
|
|
|
+ wrapper.set(SceneCooperationCount::getCount,users.size() + size);
|
|
|
+ this.update(wrapper);
|
|
|
}
|
|
|
}
|
|
|
- if(!updateList.isEmpty()){
|
|
|
- LambdaUpdateWrapper<SceneCooperationCount> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.in(SceneCooperationCount::getId,updateList);
|
|
|
- wrapper.set(SceneCooperationCount::getCount,size);
|
|
|
- this.update(wrapper);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Override
|