Commit 0e318103 authored by wdy's avatar wdy

标准下检验项排序

parent 2ce14da7
......@@ -9,7 +9,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Transactional
......@@ -21,6 +25,23 @@ public class StandardInspectionItemRelationServiceImpl extends ServiceImpl<Stand
@Override
public List<DictDataVO> getByStandardId(Long standardId) {
return standardInspectionItemRelationMapper.getListByStandardId(standardId);
List<DictDataVO> list = standardInspectionItemRelationMapper.getListByStandardId(standardId);
// 定义期望的排序关键字
List<String> desiredOrder = Arrays.asList("sraif", "grfis", "trfis");
// 使用流API对list进行排序
List<DictDataVO> sortedList = new ArrayList<>();
// 首先,创建一个映射表,键为dictValue,值为DictDataVO对象
Map<String, DictDataVO> map = list.stream().collect(Collectors.toMap(DictDataVO::getDictValue, vo -> vo));
// 然后,根据desiredOrder中的顺序从映射表中提取元素
for (String order : desiredOrder) {
if (map.containsKey(order)) {
sortedList.add(map.get(order));
}
}
return sortedList;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment