|
@@ -16,8 +16,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -102,4 +104,38 @@ public class AgentNewCameraServiceImpl extends ServiceImpl<IAgentNewCameraMapper
|
|
list.forEach(e -> map.put(e.getCameraId(),e));
|
|
list.forEach(e -> map.put(e.getCameraId(),e));
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void delByCameraIds(List<Long> cameraIds) {
|
|
|
|
+ List<CameraDetail> cameraDetails = cameraDetailService.getByCameraIds(cameraIds);
|
|
|
|
+ if(cameraDetails == null || cameraDetails.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<AgentNewCamera> agentNewCameraList = this.getByCameraIds(cameraIds);
|
|
|
|
+ if(agentNewCameraList == null || agentNewCameraList.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ HashMap<Long,CameraDetail> cameraMap = new HashMap<>();
|
|
|
|
+ cameraDetails.forEach(e -> cameraMap.put(e.getCameraId(),e));
|
|
|
|
+
|
|
|
|
+ List<Integer> rmList = new ArrayList<>();
|
|
|
|
+ for (AgentNewCamera agentNewCamera : agentNewCameraList) {
|
|
|
|
+ CameraDetail cameraDetail = cameraMap.get(agentNewCamera.getCameraId());
|
|
|
|
+ if(cameraDetail !=null && (cameraDetail.getAgentId() == null || !cameraDetail.getAgentId().equals(agentNewCamera.getAgentId()))){
|
|
|
|
+ rmList.add(agentNewCamera.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(!rmList.isEmpty()){
|
|
|
|
+ this.removeByIds(rmList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<AgentNewCamera> getByCameraIds(List<Long> cameraIds) {
|
|
|
|
+ if(cameraIds.isEmpty()){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ LambdaQueryWrapper<AgentNewCamera> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.in(AgentNewCamera::getCameraId,cameraIds);
|
|
|
|
+ return this.list(wrapper);
|
|
|
|
+ }
|
|
}
|
|
}
|