This commit is contained in:
parent
d35c87033d
commit
2460c18a01
|
|
@ -282,6 +282,7 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
extracted(list);
|
||||||
// 查询在库具体编码code
|
// 查询在库具体编码code
|
||||||
List<StorageInfo> codeList = complexQueryMapper.selectMaCodeByTypeId(bean);
|
List<StorageInfo> codeList = complexQueryMapper.selectMaCodeByTypeId(bean);
|
||||||
// 1. 创建一个 Set 存储 codeList 中的 typeId 和 maCode 的组合键
|
// 1. 创建一个 Set 存储 codeList 中的 typeId 和 maCode 的组合键
|
||||||
|
|
@ -309,6 +310,34 @@ public class ComplexQueryServiceImpl implements ComplexQueryService {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去重maCode,保留最新的一个
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
private void extracted(List<StorageInfo> list) {
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
Map<String, StorageInfo> map = new HashMap<>();
|
||||||
|
for (StorageInfo storageInfo : list) {
|
||||||
|
String maCode = storageInfo.getMaCode();
|
||||||
|
// 如果map中没有这个maCode,直接添加
|
||||||
|
if (!map.containsKey(maCode)) {
|
||||||
|
map.put(maCode, storageInfo);
|
||||||
|
} else {
|
||||||
|
// 如果map中已经有这个maCode,比较inputTime
|
||||||
|
StorageInfo existing = map.get(maCode);
|
||||||
|
|
||||||
|
// 如果当前的storageInfo的inputTime更晚,更新map中的值
|
||||||
|
if (storageInfo.getInputTime().after(existing.getInputTime())) {
|
||||||
|
map.put(maCode, storageInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 最后将map中的所有最新的StorageInfo对象放入list
|
||||||
|
list.clear();
|
||||||
|
list.addAll(map.values());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询在用设备详情
|
* 查询在用设备详情
|
||||||
* @param bean
|
* @param bean
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue