update 新增小程序查询枪列表根据状态排序

This commit is contained in:
Lemon
2025-05-30 13:10:47 +08:00
parent cbbee289fb
commit 19fe926856

View File

@@ -440,6 +440,19 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
List<PileConnectorInfoVO> pileConnectorInfoList = pileConnectorInfoMapper.getPileConnectorInfoList(pileSns, connectorIds, connectorCodeList);
// 根据枪口状态排序
// 定义 status 的优先级(值越小,优先级越高)
Map<Integer, Integer> priority = Collections.unmodifiableMap(new HashMap<Integer, Integer>() {{
put(Integer.parseInt(PileConnectorDataBaseStatusEnum.FREE.getValue()), 1); // 空闲 → 1
put(Integer.parseInt(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue()), 2); // 占用 → 2
put(Integer.parseInt(PileConnectorDataBaseStatusEnum.FAULT.getValue()), 3); // 故障 → 3
put(Integer.parseInt(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue()), 4); // 离线 → 4
}});
pileConnectorInfoList.sort(
Comparator.comparingInt((PileConnectorInfoVO vo) -> priority.get(vo.getStatus()))
.thenComparing(PileConnectorInfoVO::getPileConnectorCode) // 状态相同则按枪口号排序
);
PageInfo<PileConnectorInfoVO> pageInfo = new PageInfo<>(pileConnectorInfoList);
// 查询枪口当前订单