feat: 支持调度页面分组拖拽排序
- SaveDispatchDTO 新增 groupOrders 字段支持分组排序 - saveDispatch 方法处理分组排序,更新 schedule_detail.sort_order 和 schedule_group.display_order Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot]
parent
adeeeb4be2
commit
3ed0bf266a
@@ -26,6 +26,12 @@ public class SaveDispatchDTO {
|
||||
@Schema(description = "调整列表")
|
||||
private List<DetailAdjustment> adjustments;
|
||||
|
||||
/**
|
||||
* 分组排序列表
|
||||
*/
|
||||
@Schema(description = "分组排序列表")
|
||||
private List<GroupOrder> groupOrders;
|
||||
|
||||
/**
|
||||
* 明细调整
|
||||
*/
|
||||
@@ -47,6 +53,39 @@ public class SaveDispatchDTO {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组排序
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "分组排序")
|
||||
public static class GroupOrder {
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
@Schema(description = "分组ID")
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 分组顺序
|
||||
*/
|
||||
@Schema(description = "分组顺序")
|
||||
private Integer groupOrder;
|
||||
|
||||
/**
|
||||
* 场地ID
|
||||
*/
|
||||
@Schema(description = "场地ID")
|
||||
private Long venueId;
|
||||
|
||||
/**
|
||||
* 时间段索引
|
||||
*/
|
||||
@Schema(description = "时间段索引")
|
||||
private Integer timeSlotIndex;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 参赛者顺序
|
||||
*/
|
||||
|
||||
+32
-9
@@ -968,17 +968,40 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean saveDispatch(org.springblade.modules.martial.pojo.dto.SaveDispatchDTO dto) {
|
||||
if (dto.getAdjustments() == null || dto.getAdjustments().isEmpty()) {
|
||||
return true;
|
||||
// 1. 处理分组排序
|
||||
if (dto.getGroupOrders() != null && !dto.getGroupOrders().isEmpty()) {
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.GroupOrder go : dto.getGroupOrders()) {
|
||||
if (go.getGroupId() == null || go.getGroupOrder() == null) {
|
||||
continue;
|
||||
}
|
||||
// 更新 schedule_detail 表中该分组的 sort_order
|
||||
List<MartialScheduleDetail> details = scheduleDetailMapper.selectList(
|
||||
new QueryWrapper<MartialScheduleDetail>()
|
||||
.eq("schedule_group_id", go.getGroupId())
|
||||
.eq("is_deleted", 0)
|
||||
);
|
||||
for (MartialScheduleDetail detail : details) {
|
||||
detail.setSortOrder(go.getGroupOrder());
|
||||
scheduleDetailMapper.updateById(detail);
|
||||
}
|
||||
// 同时更新 schedule_group 表的 display_order
|
||||
MartialScheduleGroup group = scheduleGroupMapper.selectById(go.getGroupId());
|
||||
if (group != null) {
|
||||
group.setDisplayOrder(go.getGroupOrder());
|
||||
scheduleGroupMapper.updateById(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量更新所有参赛者的出场顺序
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.DetailAdjustment adjustment : dto.getAdjustments()) {
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.ParticipantOrder po : adjustment.getParticipants()) {
|
||||
MartialScheduleParticipant participant = scheduleParticipantMapper.selectById(po.getId());
|
||||
if (participant != null) {
|
||||
participant.setPerformanceOrder(po.getPerformanceOrder());
|
||||
scheduleParticipantMapper.updateById(participant);
|
||||
// 2. 处理参赛者出场顺序
|
||||
if (dto.getAdjustments() != null && !dto.getAdjustments().isEmpty()) {
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.DetailAdjustment adjustment : dto.getAdjustments()) {
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.ParticipantOrder po : adjustment.getParticipants()) {
|
||||
MartialScheduleParticipant participant = scheduleParticipantMapper.selectById(po.getId());
|
||||
if (participant != null) {
|
||||
participant.setPerformanceOrder(po.getPerformanceOrder());
|
||||
scheduleParticipantMapper.updateById(participant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+32
-9
@@ -172,17 +172,40 @@ public class ScheduleDispatchServiceImpl implements IScheduleDispatchService {
|
||||
@CacheEvict(value = "scheduleResult", allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean saveDispatch(org.springblade.modules.martial.pojo.dto.SaveDispatchDTO dto) {
|
||||
if (dto.getAdjustments() == null || dto.getAdjustments().isEmpty()) {
|
||||
return true;
|
||||
// 1. 处理分组排序
|
||||
if (dto.getGroupOrders() != null && !dto.getGroupOrders().isEmpty()) {
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.GroupOrder go : dto.getGroupOrders()) {
|
||||
if (go.getGroupId() == null || go.getGroupOrder() == null) {
|
||||
continue;
|
||||
}
|
||||
// 更新 schedule_detail 表中该分组的 sort_order
|
||||
List<MartialScheduleDetail> details = scheduleDetailMapper.selectList(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<MartialScheduleDetail>()
|
||||
.eq("schedule_group_id", go.getGroupId())
|
||||
.eq("is_deleted", 0)
|
||||
);
|
||||
for (MartialScheduleDetail detail : details) {
|
||||
detail.setSortOrder(go.getGroupOrder());
|
||||
scheduleDetailMapper.updateById(detail);
|
||||
}
|
||||
// 同时更新 schedule_group 表的 display_order
|
||||
MartialScheduleGroup group = scheduleGroupMapper.selectById(go.getGroupId());
|
||||
if (group != null) {
|
||||
group.setDisplayOrder(go.getGroupOrder());
|
||||
scheduleGroupMapper.updateById(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量更新所有参赛者的出场顺序
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.DetailAdjustment adjustment : dto.getAdjustments()) {
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.ParticipantOrder po : adjustment.getParticipants()) {
|
||||
MartialScheduleParticipant participant = scheduleParticipantMapper.selectById(po.getId());
|
||||
if (participant != null) {
|
||||
participant.setPerformanceOrder(po.getPerformanceOrder());
|
||||
scheduleParticipantMapper.updateById(participant);
|
||||
// 2. 处理参赛者出场顺序
|
||||
if (dto.getAdjustments() != null && !dto.getAdjustments().isEmpty()) {
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.DetailAdjustment adjustment : dto.getAdjustments()) {
|
||||
for (org.springblade.modules.martial.pojo.dto.SaveDispatchDTO.ParticipantOrder po : adjustment.getParticipants()) {
|
||||
MartialScheduleParticipant participant = scheduleParticipantMapper.selectById(po.getId());
|
||||
if (participant != null) {
|
||||
participant.setPerformanceOrder(po.getPerformanceOrder());
|
||||
scheduleParticipantMapper.updateById(participant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user