| | |
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import com.ruoyi.common.utils.DateUtils;
|
| | | import com.ruoyi.device.channel.domain.ArdChannel;
|
| | | import com.ruoyi.media.service.IMediaService;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | }
|
| | | return vtduMapper.deleteVtduByCameraId(cameraId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * @return
|
| | | * @Author 刘苏义
|
| | | * @Description 清除所有流媒体数据
|
| | | * @Date 2024/7/10 13:31
|
| | | * @Param
|
| | | */
|
| | | public void clearVtdu() {
|
| | | vtduMapper.clearVtdu();
|
| | | }
|
| | |
|
| | |
|
| | | //需要更新的(流媒体和vtdu相同)
|
| | | @Override
|
| | | public List<Vtdu> sameList(List<Vtdu> vtdus, List<String> names) {
|
| | | return vtdus.stream().filter(vtdu -> names.contains(vtdu.getName())).collect(Collectors.toList());
|
| | | }
|
| | |
|
| | | //需要删除的(流媒体中多的)
|
| | | @Override
|
| | | public List<String> diffListToDel(List<Vtdu> vtdus, List<String> names) {
|
| | | if (vtdus.size() >= names.size()) {
|
| | | List<String> nameList = vtdus.stream().map(Vtdu::getName)
|
| | | .filter(item -> !names.contains(item))
|
| | | .collect(Collectors.toList());
|
| | | return nameList;
|
| | | } else {
|
| | |
|
| | | List<String> nameList = names.stream().filter(item -> !vtdus.stream().map(Vtdu::getName).collect(Collectors.toList()).contains(item))
|
| | | .collect(Collectors.toList());
|
| | | return nameList;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | //需要新增的(流媒体中少的)
|
| | | @Override
|
| | | public List<Vtdu> diffListToAdd(List<Vtdu> vtdus, List<String> names) {
|
| | | return vtdus.stream().filter(vtdu -> !names.contains(vtdu.getName())).collect(Collectors.toList());
|
| | | }
|
| | |
|
| | | /**
|
| | | * @Author 刘苏义
|
| | | * @Description 同步本地vtdu库和流媒体中的数据
|
| | | * @Date 2024/7/10 15:26
|
| | | * @Param vtdus vtdu库的集合
|
| | | * @Param names 流媒体的name集合
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public void asyncVtdu(List<Vtdu> vtdus, List<String> names) {
|
| | | //需要更新的数据,参数顺序注意
|
| | | sameList(vtdus, names).stream().forEach(vtdu -> {
|
| | | mediaService.editPath(vtdu.getName(), vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode());
|
| | | });
|
| | | //需要删除的数据
|
| | | diffListToDel(vtdus, names).stream().forEach(name -> {
|
| | | mediaService.removePath(name);
|
| | | });
|
| | | //需要新增的数据
|
| | | diffListToAdd(vtdus, names).stream().forEach(vtdu -> {
|
| | | mediaService.addPath(vtdu.getName(), vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode());
|
| | | });
|
| | | }
|
| | | }
|