|
@@ -28,7 +28,9 @@ import shop.alien.store.service.SportsEquipmentFacilityService;
|
|
|
import shop.alien.store.service.SportsFacilityAreaService;
|
|
import shop.alien.store.service.SportsFacilityAreaService;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -159,8 +161,11 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
|
|
|
|
|
List<SportsEquipmentFacility> facilityList = facilityMapper.selectList(queryWrapper);
|
|
List<SportsEquipmentFacility> facilityList = facilityMapper.selectList(queryWrapper);
|
|
|
|
|
|
|
|
- // 2. 收集所有设备ID(从fitnessEquipmentIds字段中提取)
|
|
|
|
|
|
|
+ // 2. 收集所有设备ID(从fitnessEquipmentIds字段中提取),并建立设备ID与设施的映射关系
|
|
|
List<Integer> equipmentIdList = new ArrayList<>();
|
|
List<Integer> equipmentIdList = new ArrayList<>();
|
|
|
|
|
+ // 设备ID -> 设施对象的映射(用于获取displayInStoreDetail)
|
|
|
|
|
+ Map<Integer, SportsEquipmentFacility> equipmentIdToFacilityMap = new HashMap<>();
|
|
|
|
|
+
|
|
|
for (SportsEquipmentFacility facility : facilityList) {
|
|
for (SportsEquipmentFacility facility : facilityList) {
|
|
|
String fitnessEquipmentIds = facility.getFitnessEquipmentIds();
|
|
String fitnessEquipmentIds = facility.getFitnessEquipmentIds();
|
|
|
if (StringUtils.isNotBlank(fitnessEquipmentIds)) {
|
|
if (StringUtils.isNotBlank(fitnessEquipmentIds)) {
|
|
@@ -170,8 +175,17 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
if (StringUtils.isNotBlank(trimmedId)) {
|
|
if (StringUtils.isNotBlank(trimmedId)) {
|
|
|
try {
|
|
try {
|
|
|
Integer equipmentId = Integer.parseInt(trimmedId);
|
|
Integer equipmentId = Integer.parseInt(trimmedId);
|
|
|
- if (equipmentId > 0 && !equipmentIdList.contains(equipmentId)) {
|
|
|
|
|
- equipmentIdList.add(equipmentId);
|
|
|
|
|
|
|
+ if (equipmentId > 0) {
|
|
|
|
|
+ if (!equipmentIdList.contains(equipmentId)) {
|
|
|
|
|
+ equipmentIdList.add(equipmentId);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果设备ID还没有映射,或者当前设施的displayInStoreDetail为1(显示),则更新映射
|
|
|
|
|
+ // 优先使用displayInStoreDetail=1的设施
|
|
|
|
|
+ if (!equipmentIdToFacilityMap.containsKey(equipmentId)
|
|
|
|
|
+ || (facility.getDisplayInStoreDetail() != null
|
|
|
|
|
+ && facility.getDisplayInStoreDetail() == 1)) {
|
|
|
|
|
+ equipmentIdToFacilityMap.put(equipmentId, facility);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (NumberFormatException e) {
|
|
} catch (NumberFormatException e) {
|
|
|
log.warn("解析设备ID失败,跳过无效ID:{},storeId={},areaId={}",
|
|
log.warn("解析设备ID失败,跳过无效ID:{},storeId={},areaId={}",
|
|
@@ -192,13 +206,24 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
List<FitnessEquipmentInfo> equipmentList = new ArrayList<>(
|
|
List<FitnessEquipmentInfo> equipmentList = new ArrayList<>(
|
|
|
fitnessEquipmentInfoService.listByIds(equipmentIdList));
|
|
fitnessEquipmentInfoService.listByIds(equipmentIdList));
|
|
|
|
|
|
|
|
- // 5. 过滤掉已删除和禁用的设备,并按sortOrder排序
|
|
|
|
|
|
|
+ // 5. 过滤掉已删除和禁用的设备,设置displayInStoreDetail字段,并按sortOrder排序
|
|
|
List<FitnessEquipmentInfo> resultList = equipmentList.stream()
|
|
List<FitnessEquipmentInfo> resultList = equipmentList.stream()
|
|
|
.filter(equipment -> equipment != null
|
|
.filter(equipment -> equipment != null
|
|
|
&& equipment.getDeleteFlag() != null
|
|
&& equipment.getDeleteFlag() != null
|
|
|
&& equipment.getDeleteFlag() == DELETE_FLAG_NOT_DELETED
|
|
&& equipment.getDeleteFlag() == DELETE_FLAG_NOT_DELETED
|
|
|
&& equipment.getStatus() != null
|
|
&& equipment.getStatus() != null
|
|
|
&& equipment.getStatus() == STATUS_ENABLED)
|
|
&& equipment.getStatus() == STATUS_ENABLED)
|
|
|
|
|
+ .map(equipment -> {
|
|
|
|
|
+ // 从设施映射中获取displayInStoreDetail值
|
|
|
|
|
+ SportsEquipmentFacility facility = equipmentIdToFacilityMap.get(equipment.getId());
|
|
|
|
|
+ if (facility != null && facility.getDisplayInStoreDetail() != null) {
|
|
|
|
|
+ equipment.setDisplayInStoreDetail(facility.getDisplayInStoreDetail());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果没有找到对应的设施,设置默认值1(显示)
|
|
|
|
|
+ equipment.setDisplayInStoreDetail(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return equipment;
|
|
|
|
|
+ })
|
|
|
.sorted((e1, e2) -> {
|
|
.sorted((e1, e2) -> {
|
|
|
Integer sort1 = e1.getSortOrder() != null ? e1.getSortOrder() : 0;
|
|
Integer sort1 = e1.getSortOrder() != null ? e1.getSortOrder() : 0;
|
|
|
Integer sort2 = e2.getSortOrder() != null ? e2.getSortOrder() : 0;
|
|
Integer sort2 = e2.getSortOrder() != null ? e2.getSortOrder() : 0;
|