فهرست منبع

bug2866修改,当演出人员下线是,不显示演出人员的信息

zhangchen 2 ماه پیش
والد
کامیت
081f34a338
1فایلهای تغییر یافته به همراه192 افزوده شده و 2 حذف شده
  1. 192 2
      alien-store/src/main/java/shop/alien/store/service/impl/PerformanceListServiceImpl.java

+ 192 - 2
alien-store/src/main/java/shop/alien/store/service/impl/PerformanceListServiceImpl.java

@@ -197,6 +197,22 @@ public class PerformanceListServiceImpl implements PerformanceListService {
     }
 
     /**
+     * 转换为VO列表(用于按日期分组查询,过滤下线演出人员)
+     *
+     * @param performances 演出列表
+     * @return VO列表
+     */
+    private List<PerformanceListVo> convertToVoListForGroupByDate(List<BarPerformance> performances) {
+        if (performances == null || performances.isEmpty()) {
+            return new ArrayList<>();
+        }
+
+        return performances.stream()
+                .map(this::convertToVoForGroupByDate)
+                .collect(Collectors.toList());
+    }
+
+    /**
      * 转换为VO
      *
      * @param performance 演出信息
@@ -228,6 +244,37 @@ public class PerformanceListServiceImpl implements PerformanceListService {
     }
 
     /**
+     * 转换为VO(用于按日期分组查询,过滤下线演出人员)
+     *
+     * @param performance 演出信息
+     * @return VO对象
+     */
+    private PerformanceListVo convertToVoForGroupByDate(BarPerformance performance) {
+        PerformanceListVo vo = new PerformanceListVo();
+        vo.setId(performance.getId());
+        vo.setPerformanceName(performance.getPerformanceName());
+        vo.setPerformancePoster(performance.getPerformancePoster());
+        vo.setPerformanceType(performance.getPerformanceType());
+
+        // 设置演出者信息(过滤下线演出人员)
+        vo.setPerformersInfo(buildPerformersInfoFilterOffline(performance.getStaffConfigIds()));
+
+        // 设置日期范围
+        vo.setDateRange(buildDateRange(performance));
+
+        // 设置演出时间安排
+        vo.setScheduleInfo(buildScheduleInfo(performance));
+
+        // 设置演出风格(直接返回表中的值,不查询字典)
+        vo.setPerformanceStyle(performance.getPerformanceStyle());
+
+        // 设置演出人员头像列表(过滤下线演出人员)
+        vo.setStaffImageList(queryStaffImageListFilterOffline(performance.getStaffConfigIds()));
+
+        return vo;
+    }
+
+    /**
      * 构建演出者信息
      * <p>
      * 从员工ID列表中查询第一个有名字的员工,显示格式:
@@ -295,6 +342,88 @@ public class PerformanceListServiceImpl implements PerformanceListService {
     }
 
     /**
+     * 构建演出者信息(过滤下线演出人员)
+     * <p>
+     * 从员工ID列表中查询第一个有名字且上线的员工,显示格式:
+     * - 1人:显示员工名字
+     * - 多人:显示"xx等X人"
+     * 只统计上线的员工数量
+     * </p>
+     *
+     * @param staffConfigIds 员工配置ID字符串(逗号分隔)
+     * @return 演出者信息(如:刘能等7人,仅包含上线员工)
+     */
+    private String buildPerformersInfoFilterOffline(String staffConfigIds) {
+        if (StringUtils.isEmpty(staffConfigIds)) {
+            return "";
+        }
+
+        try {
+            String[] ids = staffConfigIds.split(",");
+            List<Integer> staffIdList = new ArrayList<>();
+            
+            // 解析所有有效的员工ID
+            for (String idStr : ids) {
+                if (StringUtils.isNotEmpty(idStr.trim())) {
+                    try {
+                        Integer staffId = Integer.parseInt(idStr.trim());
+                        if (staffId > 0) {
+                            staffIdList.add(staffId);
+                        }
+                    } catch (NumberFormatException e) {
+                        log.warn("解析员工配置ID失败,无效的ID:{}", idStr);
+                    }
+                }
+            }
+
+            if (staffIdList.isEmpty()) {
+                return "";
+            }
+
+            // 批量查询员工信息
+            List<StoreStaffConfig> staffList = storeStaffConfigMapper.selectBatchIds(staffIdList);
+            
+            // 过滤出上线的员工
+            List<StoreStaffConfig> onlineStaffList = new ArrayList<>();
+            if (staffList != null && !staffList.isEmpty()) {
+                for (StoreStaffConfig staff : staffList) {
+                    if (staff != null 
+                            && CommonConstant.DELETE_FLAG_UNDELETE.equals(staff.getDeleteFlag())
+                            && "1".equals(staff.getStatus())
+                            && CommonConstant.ONLINE_STATUS.equals(staff.getOnlineStatus())) {
+                        onlineStaffList.add(staff);
+                    }
+                }
+            }
+
+            if (onlineStaffList.isEmpty()) {
+                return "";
+            }
+
+            int count = onlineStaffList.size();
+            String firstName = null;
+
+            // 找到第一个有名字的上线员工
+            for (StoreStaffConfig staff : onlineStaffList) {
+                if (StringUtils.isNotEmpty(staff.getName())) {
+                    firstName = staff.getName();
+                    break; // 找到第一个有名字的员工就退出
+                }
+            }
+
+            // 根据人数和是否找到名字来构建返回信息
+            if (count == 1) {
+                return firstName != null ? firstName : "1人";
+            } else {
+                return firstName != null ? firstName + "等" + count + "人" : count + "人";
+            }
+        } catch (Exception e) {
+            log.error("构建演出者信息异常(过滤下线),staffConfigIds={},异常信息:{}", staffConfigIds, e.getMessage(), e);
+            return "";
+        }
+    }
+
+    /**
      * 查询演出人员头像列表
      * <p>
      * 根据员工配置ID字符串(逗号分隔)查询store_staff_config表,获取所有员工的头像
@@ -352,6 +481,67 @@ public class PerformanceListServiceImpl implements PerformanceListService {
     }
 
     /**
+     * 查询演出人员头像列表(过滤下线演出人员)
+     * <p>
+     * 根据员工配置ID字符串(逗号分隔)查询store_staff_config表,只获取上线员工的头像
+     * </p>
+     *
+     * @param staffConfigIds 员工配置ID字符串(逗号分隔)
+     * @return 员工头像URL列表(仅包含上线员工)
+     */
+    private List<String> queryStaffImageListFilterOffline(String staffConfigIds) {
+        List<String> imageList = new ArrayList<>();
+        
+        if (StringUtils.isEmpty(staffConfigIds)) {
+            return imageList;
+        }
+
+        try {
+            String[] ids = staffConfigIds.split(",");
+            List<Integer> staffIdList = new ArrayList<>();
+            
+            // 解析所有有效的员工ID
+            for (String idStr : ids) {
+                if (StringUtils.isNotEmpty(idStr.trim())) {
+                    try {
+                        Integer staffId = Integer.parseInt(idStr.trim());
+                        if (staffId > 0) {
+                            staffIdList.add(staffId);
+                        }
+                    } catch (NumberFormatException e) {
+                        log.warn("解析员工配置ID失败,无效的ID:{}", idStr);
+                    }
+                }
+            }
+
+            if (staffIdList.isEmpty()) {
+                return imageList;
+            }
+
+            // 批量查询员工信息
+            List<StoreStaffConfig> staffList = storeStaffConfigMapper.selectBatchIds(staffIdList);
+            
+            if (staffList != null && !staffList.isEmpty()) {
+                // 只提取上线且非空的头像URL
+                for (StoreStaffConfig staff : staffList) {
+                    if (staff != null 
+                            && CommonConstant.DELETE_FLAG_UNDELETE.equals(staff.getDeleteFlag())
+                            && "1".equals(staff.getStatus())
+                            && CommonConstant.ONLINE_STATUS.equals(staff.getOnlineStatus())
+                            && StringUtils.isNotEmpty(staff.getStaffImage())) {
+                        imageList.add(staff.getStaffImage());
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("查询演出人员头像列表异常(过滤下线),staffConfigIds={},异常信息:{}", 
+                    staffConfigIds, e.getMessage(), e);
+        }
+
+        return imageList;
+    }
+
+    /**
      * 构建日期范围
      *
      * @param performance 演出信息
@@ -593,8 +783,8 @@ public class PerformanceListServiceImpl implements PerformanceListService {
                 return result;
             }
 
-            // 转换为VO列表
-            List<PerformanceListVo> voList = convertToVoList(performances);
+            // 转换为VO列表(过滤下线演出人员)
+            List<PerformanceListVo> voList = convertToVoListForGroupByDate(performances);
 
             // 生成演出日期映射(日期 -> 演出列表)
             Map<String, List<PerformanceListVo>> datePerformanceMap = generateDatePerformanceMap(performances, voList);