diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java index 66f06bdf1..34a5ee062 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java @@ -440,6 +440,19 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService { List pileConnectorInfoList = pileConnectorInfoMapper.getPileConnectorInfoList(pileSns, connectorIds, connectorCodeList); + // 根据枪口状态排序 + // 定义 status 的优先级(值越小,优先级越高) + Map priority = Collections.unmodifiableMap(new HashMap() {{ + 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 pageInfo = new PageInfo<>(pileConnectorInfoList); // 查询枪口当前订单