|
|
|
@ -42,7 +42,8 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 物流站点 服务类 |
|
|
|
* 物流站点 服务类 |
|
|
|
@ -82,12 +83,13 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, Station> |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<StationVO> getStationList(IPage<StationVO> page, Station station) { |
|
|
|
public IPage<StationVO> getStationList(IPage<StationVO> page, Station station) { |
|
|
|
|
|
|
|
|
|
|
|
List<StationVO> stationList = baseMapper.selectStationList(page, station); |
|
|
|
List<StationVO> stationList = baseMapper.selectStationList(page, station); |
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(stationList)) { |
|
|
|
if (CollectionUtils.isEmpty(stationList)) { |
|
|
|
return page.setRecords(stationList); |
|
|
|
return page.setRecords(stationList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 填充工作中心名称
|
|
|
|
for (StationVO stationVO : stationList) { |
|
|
|
for (StationVO stationVO : stationList) { |
|
|
|
if (null != stationVO && null != stationVO.getWcId()) { |
|
|
|
if (null != stationVO && null != stationVO.getWcId()) { |
|
|
|
WorkCenter workCenter = workCenterService.getById(stationVO.getWcId()); |
|
|
|
WorkCenter workCenter = workCenterService.getById(stationVO.getWcId()); |
|
|
|
@ -95,10 +97,60 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, Station> |
|
|
|
stationVO.setWcName(workCenter.getWcName()); |
|
|
|
stationVO.setWcName(workCenter.getWcName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 合并数据:除wcId和wcName外其他字段相同的记录,wcName用顿号拼接
|
|
|
|
|
|
|
|
List<StationVO> mergedList = mergeStationList(stationList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return page.setRecords(mergedList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return page.setRecords(stationList); |
|
|
|
/** |
|
|
|
|
|
|
|
* 合并站点列表:除wcId和wcName外其他字段相同的记录,wcName用顿号拼接 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<StationVO> mergeStationList(List<StationVO> stationList) { |
|
|
|
|
|
|
|
// 使用Map分组,key为除wcId和wcName外的其他字段组合
|
|
|
|
|
|
|
|
Map<String, List<StationVO>> groupMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (StationVO vo : stationList) { |
|
|
|
|
|
|
|
String key = buildGroupKey(vo); |
|
|
|
|
|
|
|
groupMap.computeIfAbsent(key, k -> new ArrayList<>()).add(vo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<StationVO> result = new ArrayList<>(); |
|
|
|
|
|
|
|
for (List<StationVO> group : groupMap.values()) { |
|
|
|
|
|
|
|
if (group.size() == 1) { |
|
|
|
|
|
|
|
result.add(group.get(0)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 合并:保留第一条,wcName用顿号拼接(去重)
|
|
|
|
|
|
|
|
StationVO merged = group.get(0); |
|
|
|
|
|
|
|
String mergedWcName = group.stream() |
|
|
|
|
|
|
|
.map(StationVO::getWcName) |
|
|
|
|
|
|
|
.filter(name -> !StringUtils.isEmpty(name)) |
|
|
|
|
|
|
|
.distinct() |
|
|
|
|
|
|
|
.collect(Collectors.joining("、")); |
|
|
|
|
|
|
|
merged.setWcName(mergedWcName); |
|
|
|
|
|
|
|
result.add(merged); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 构建分组key(排除wcId和wcName) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String buildGroupKey(StationVO vo) { |
|
|
|
|
|
|
|
// 使用站点核心字段构建分组key
|
|
|
|
|
|
|
|
return String.join("|", |
|
|
|
|
|
|
|
String.valueOf(vo.getId()), |
|
|
|
|
|
|
|
vo.getStationName(), |
|
|
|
|
|
|
|
vo.getStationPosition(), |
|
|
|
|
|
|
|
vo.getStationCode(), |
|
|
|
|
|
|
|
String.valueOf(vo.getStationStatus()), |
|
|
|
|
|
|
|
vo.getRemark(), |
|
|
|
|
|
|
|
vo.getStationRegion() |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|