|
@@ -133,7 +133,7 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void updateArchiveFileSort(List<ArchiveFileVO> list, List<ArchiveFileVO> oldList) {
|
|
|
|
|
|
+ public void updateArchiveFileSort(List<ArchiveFileVO> list) {
|
|
List<Integer> listInt = new ArrayList<>();
|
|
List<Integer> listInt = new ArrayList<>();
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
listInt.add(list.get(i).getSort());
|
|
listInt.add(list.get(i).getSort());
|
|
@@ -143,65 +143,17 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
|
|
StringBuffer ids2 = new StringBuffer();
|
|
StringBuffer ids2 = new StringBuffer();
|
|
Map<Long, Integer> mapkey = new HashMap<>();
|
|
Map<Long, Integer> mapkey = new HashMap<>();
|
|
Collections.sort(listInt);
|
|
Collections.sort(listInt);
|
|
-
|
|
|
|
- // 创建原始ID到原始nodeId的映射(基于oldList)
|
|
|
|
- Map<Long, String> originalIdToNodeIdMap = new HashMap<>();
|
|
|
|
- // 创建原始ID到原始排序的映射(基于oldList)
|
|
|
|
- Map<Long, Integer> originalIdToSortMap = new HashMap<>();
|
|
|
|
- // 创建原始排序位置到nodeId的映射(基于oldList)
|
|
|
|
- Map<Integer, String> originalSortToNodeIdMap = new HashMap<>();
|
|
|
|
-
|
|
|
|
- for (ArchiveFileVO vo : oldList) {
|
|
|
|
- originalIdToNodeIdMap.put(vo.getId(), vo.getNodeId());
|
|
|
|
- originalIdToSortMap.put(vo.getId(), vo.getSort());
|
|
|
|
- originalSortToNodeIdMap.put(vo.getSort(), vo.getNodeId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 找出所有位置发生变化的文件ID
|
|
|
|
- Set<Long> movedFileIds = new HashSet<>();
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
- ArchiveFileVO currentVO = list.get(i);
|
|
|
|
- Integer originalSort = originalIdToSortMap.get(currentVO.getId());
|
|
|
|
- if (!listInt.get(i).equals(originalSort)) {
|
|
|
|
- movedFileIds.add(currentVO.getId());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
- ArchiveFileVO currentVO = list.get(i);
|
|
|
|
- ids2.append(currentVO.getId() + ",");
|
|
|
|
-
|
|
|
|
- // 保存原始数据
|
|
|
|
- String originalNodeId = originalIdToNodeIdMap.get(currentVO.getId());
|
|
|
|
- Integer originalSort = originalIdToSortMap.get(currentVO.getId());
|
|
|
|
-
|
|
|
|
- // 设置新的排序值
|
|
|
|
- currentVO.setSort(listInt.get(i));
|
|
|
|
- currentVO.setArchiveSort(i);
|
|
|
|
-
|
|
|
|
- // 只有位置发生变化的文件才需要更新nodeId
|
|
|
|
- if (movedFileIds.contains(currentVO.getId())) {
|
|
|
|
- // 获取当前位置对应的原始nodeId(这个位置原来属于哪个nodeId)
|
|
|
|
- Integer currentPositionOriginalSort = listInt.get(i);
|
|
|
|
- String positionOriginalNodeId = originalSortToNodeIdMap.get(currentPositionOriginalSort);
|
|
|
|
-
|
|
|
|
- // 如果当前位置的原始nodeId与当前文件的原始nodeId不同,则更新
|
|
|
|
- if (positionOriginalNodeId != null && !positionOriginalNodeId.equals(originalNodeId)) {
|
|
|
|
- currentVO.setNodeId(positionOriginalNodeId);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 位置没有变化的文件保持原来的nodeId
|
|
|
|
- currentVO.setNodeId(originalNodeId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (currentVO.getIsUpdateUrl() != null && currentVO.getIsUpdateUrl() == 1) {
|
|
|
|
- ids.append(currentVO.getId() + ",");
|
|
|
|
- if (currentVO.getRectification() != null && currentVO.getRectification() == 1) {
|
|
|
|
- currentVO.setRectification(2);
|
|
|
|
|
|
+ ids2.append(list.get(i).getId() + ",");
|
|
|
|
+ list.get(i).setSort(listInt.get(i));
|
|
|
|
+ list.get(i).setArchiveSort(i);
|
|
|
|
+ if (list.get(i).getIsUpdateUrl() != null && list.get(i).getIsUpdateUrl() == 1) {
|
|
|
|
+ ids.append(list.get(i).getId() + ",");
|
|
|
|
+ if (list.get(i).getRectification() != null && list.get(i).getRectification() == 1) {
|
|
|
|
+ list.get(i).setRectification(2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
// 删除oss文件
|
|
// 删除oss文件
|
|
if (ids != null && ids.length() > 0) {
|
|
if (ids != null && ids.length() > 0) {
|
|
List<String> removeFiles = new ArrayList<>();
|
|
List<String> removeFiles = new ArrayList<>();
|
|
@@ -274,7 +226,6 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
|
|
}
|
|
}
|
|
this.updateBatchById(JSONArray.parseArray(JSONObject.toJSONString(list), ArchiveFile.class));
|
|
this.updateBatchById(JSONArray.parseArray(JSONObject.toJSONString(list), ArchiveFile.class));
|
|
}
|
|
}
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public boolean updateArchiveFileByBoxName(Map<String, Object> jsons) {
|
|
public boolean updateArchiveFileByBoxName(Map<String, Object> jsons) {
|
|
List<Object> list = (List<Object>) jsons.get("list");
|
|
List<Object> list = (List<Object>) jsons.get("list");
|