From eef5fa4471266a9dac605b8c4ec3dfd627296017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=85=E6=88=BF?= Date: Sun, 18 Jan 2026 13:12:59 +0800 Subject: [PATCH] refactor: Complete moveScheduleGroup delegation to ScheduleDispatchService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 4.4 Complete: - Add moveScheduleGroup method to IScheduleDispatchService interface - Implement moveScheduleGroup in ScheduleDispatchServiceImpl - Add venueService dependency to ScheduleDispatchServiceImpl - Delegate moveScheduleGroup in MartialScheduleServiceImpl (61 lines → 7 lines) File size: 823 lines → 769 lines (-54 lines, -6.6%) Total reduction: 996 lines → 769 lines (-227 lines, -22.8%) Delegation Status: ✅ exportSchedule - FULLY DELEGATED ✅ exportScheduleTemplate2 - FULLY DELEGATED ✅ updateParticipantCheckInStatus - FULLY DELEGATED ✅ getDispatchData - FULLY DELEGATED ✅ adjustOrder - FULLY DELEGATED ✅ saveDispatch - FULLY DELEGATED ✅ moveScheduleGroup - FULLY DELEGATED (NEW) Progress: 7/10 methods (70%) Remaining: 3 methods (saveAndLockSchedule, saveDraftSchedule, getScheduleResult) All tests passing (482 total) --- .../buckets/.bloomcycle.bin/xl.meta | Bin 743 -> 743 bytes .../buckets/.usage-cache.bin.bkp/xl.meta | Bin 630 -> 630 bytes .../buckets/.usage-cache.bin/xl.meta | Bin 630 -> 630 bytes .../.minio.sys/buckets/.usage.json/xl.meta | Bin 2359 -> 2360 bytes .../.usage-cache.bin.bkp/xl.meta | Bin 627 -> 636 bytes .../000000-assets/.usage-cache.bin/xl.meta | Bin 627 -> 636 bytes .../assets/.usage-cache.bin.bkp/xl.meta | Bin 575 -> 575 bytes .../buckets/assets/.usage-cache.bin/xl.meta | Bin 575 -> 575 bytes .../service/IScheduleDispatchService.java | 9 +++ .../impl/MartialScheduleServiceImpl.java | 60 +--------------- .../impl/ScheduleDispatchServiceImpl.java | 66 ++++++++++++++++++ 11 files changed, 78 insertions(+), 57 deletions(-) diff --git a/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta b/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta index eb4341d3ba64d926509a5f7c045ece2c819dfd68..1d1862763bee854ee16e3e4aac90beb9f5eb3e56 100644 GIT binary patch delta 341 zcmaFP`kZxw2G4FsmD;kPBP`;1u|^Y3j0FsCeLefb!F&H=u^xT>>d71v%j?-7Y9{`% zmA5oWvPd&CGDtK?Og2hMG`BQOOiM{gHBCu1FflSTogBfaSAVKPVFzR5lDyKKoTH4v zR*~zUD)#&@YFgg0;egT=?o{D}_Zm(o-mI(Fi{VY1@nA+d0~oX{PcAJgO3f=_Sdy1o zQF69?#`5Bl#G;bal;b?CAQhQ8+2`3x>%-S2S0?AAI_KvWeXBPFjiq~T#{FslXH|Y zSR;0aMwZLbmwk^)ojdriuU2qtsM_A;W?OseYF&0>S{+V|7Lw}(;FYhRylDQ{5vAmuQqGsYB z8--L8vt;w6WK)x*Gy_Xhlf)F`l%zy+QzOe{3zMWI!{o^kjC#6F=U#nfY+RC8nv-+n zaj%(cPE)8N$L1hW=DLin->VNr?76x0H2Z|Cm-7R5Sqe|y%%~wfeU(pQaY<-FN@7Xs baUNC%Ajr(gKF{7A@_zC+#u^q;?!VFi(eOt0 delta 176 zcmeyy@{MJJ2G6dGiPz-3j<6gLO5Hut#8}|x^Od2GX87FMoq1BlkA3xoiRJZd5H%D3 z*eDpKnWZHgS*Dm6nx+{U7$sU-B%2tfnxq+|O z$G5a{zvyjhU^(g=B$vpglVfDMN=ey%#h1->%T73MOI4b@nNdT!f0a*SaY<-FN@7Xs baUNC%Ajr(ge9!K`sA}>z#u^q4^##rVo^eLX diff --git a/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta b/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta index 43e5dbfbf32d1bcf9c5a9117292d04e4429f60a8..f158d4293f8b8cad52c61745130e5140c99befcf 100644 GIT binary patch delta 176 zcmeyy@{MJJ2G4Fs71bBtkFYqnD|k;dF&220;#nK{%*VG!GDpF_@nq-3@_IIinu&jG z6jDvhlFgHnO-+*03@lAe5>t#*k`m2LjVzNbOp=lelP5glSyz4VWoT@}uRav9=jPJW>=UwH&JWmSDLi>IqlWbKRX&NuC7}f=i6yDW bc~}{MATuZXJbQP@`^n!JYgk0N|4IV@D3C?M delta 176 zcmeyy@{MJJ2G6dGiR&l+KEk4MM(E;16Jvo*KR~FM69ASdRJz$t7~>@ boQIVG2r_dr-?RHKs+#T0 diff --git a/minio_data/.minio.sys/buckets/.usage.json/xl.meta b/minio_data/.minio.sys/buckets/.usage.json/xl.meta index efc0698c97ebb8a117867f1f68863e4e2fd507bf..0883c76b354fbcbf85a59002c2cdc1ddb3bff40c 100644 GIT binary patch delta 194 zcmdlkv_oiu2G4FsmByaUM_5AIU!+YmF&0qF^As&MciXT?_`TqTm4Uhw%j490Rs|#$ zl{f}xR;3nCyvW|O1jGW;OMOE!b5k!%bVCf8_{T=UATc@7Jk{LH)WX6fH7&(BEzKy! zFxem}$=uMy*wQ3*as;EAo-Av-4rAkzywaSUqwH%s@Bfln+_d1|A*oxu+4__I3AoEjM3hOkf89NM}k) delta 193 zcmdlXv|VU|2G6dGNes-VkFfAaY^|DTVl2S+peXk41aFqD5|0_uqWWznmdB}guL?*k zDsc?XtV%7Oc#*w(35W%xm->ce=B8ej=!O_F@sEu{s$oi6vZ=XwVycCSxk+lGg^8h= ziHT{diMhF%g{5K2sqO#ET3kmw;G6dZ}+nW^U?biEfA?6aUyKm>L>bSR|XJnwcA$rX^ZfCMFpf znj57WnHrlK8zx$&O^#sHv#jAh+R50sB(F3l=g7;fzSu{eEj*&;3pZKsWwzMa@_6>4 zB}q#q9Hu^z(a!Bot&s-&jJzy4Uth8fCp7=sUS GtO5X7jCs=l delta 311 zcmeyv@|k6V2G6dGiA|!8M_4xP4B_I}%Ug{f?nVWi9q8nn!#6LC)i53>dX%^;&Y00K3#ug?PMh1y# z7KUjl=BcU17DkEYlOq`QEH8%UY+!6$l2@9ObL7EHIpZHw(@+2Fom1`HrGH}TjE_!N zuU~1+p1om3TurAXFNelf{l6>>Q&}07a8BOOs3zUN$|te7B(xwUu_X044=V!@WaebP zXZx|zYZ8-4e8-~XjEP(HOAB)H6H^uyS1~NgFJ@R&R?M(CB^O8(R~63&axsqO#ET3kmw;G6dZ}+nW^U?biEfA?6aUyKm>L>bSR|XJnwcA$rX^ZfCMFpf znj57WnHrlK8zx$&O^#sHvz+nfM<8S4lDyKKoFgx@`eGk>w(y9WFWh9km)T-x%j4OH zmLx5eaG3f;Mmx7Vkwasv{$Cb`yQ~Z@T$A@Rs!2~@<&#)k5?YXwSdx02hm`>cGIO%e zvl~y^I*CanV~c)iK~8>RO2?w)j0ua1t1dCN#(FHuFP2+WR?M(CB^O8(R~64@U}ECt zU|KYA!Lh#(DtN$uTi;b1<;W9p+$Y;85_=*j3tMf8fF+v-IMSqbF|g7&6_w4*AE5T6Z%xF3Bs+$vLvd z&1ZXw!_GP09#fVt*L|}---FNdAyZNu1S95BEj{KMBcI|e~weu$iKVp^(IyG*vXq2wWa%4`6L#XgchVEmZTo% aVPyb<%$&^kY;kdqC;w!0Vlj+aF&6;A>_(md diff --git a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta index e054dca97b9da872ba337703f71e824b3e5605ff..37c6668c5168963e54fe3226d8ccc0a9c9f51565 100644 GIT binary patch delta 176 zcmdnbvY%yw2G4FsWoHMMBP_eT&L5a)Vl3eIxr679py!PJDxHC@5vP16me;dE)J*(i zqhMfemTaD8Vq|HalxA*dk& delta 176 zcmdnbvY%yw2G6dG3H$b!9%0Ge=^i`L#8@CsvtveahvTkkP1oDKcdQPYSYFQtQ8V$6 zjY6_XqIrsOQj$rcfkld8qN%Y-YN|!5v6-onX|idmsm0_7Mm^nL7SCwL#wB^BIXOqx zXzTn8cX_;(ORh details = scheduleDetailMapper.selectList( - new QueryWrapper() - .eq("schedule_group_id", dto.getGroupId()) - .eq("is_deleted", 0) - ); - - if (details.isEmpty()) { - throw new RuntimeException("分组详情不存在"); - } - - // 3. 查询目标场地信息 - MartialVenue targetVenue = venueService.getById(dto.getTargetVenueId()); - if (targetVenue == null) { - throw new RuntimeException("目标场地不存在"); - } - - // 4. 根据时间段索引计算日期和时间 - // 假设: 0=第1天上午, 1=第1天下午, 2=第2天上午, 3=第2天下午... - // 需要从赛事信息中获取起始日期 - int dayOffset = dto.getTargetTimeSlotIndex() / 2; // 每天2个时段 - boolean isAfternoon = dto.getTargetTimeSlotIndex() % 2 == 1; - String timeSlot = isAfternoon ? "13:30" : "08:30"; - - // 获取赛事起始日期(从第一个detail中获取) - LocalDate baseDate = details.get(0).getScheduleDate(); - if (baseDate == null) { - throw new RuntimeException("无法确定赛事起始日期"); - } - - // 计算目标日期(从起始日期开始,加上dayOffset天的偏移) - // 如果当前detail的日期早于base date,需要调整 - LocalDate minDate = details.stream() - .map(MartialScheduleDetail::getScheduleDate) - .filter(Objects::nonNull) - .min(LocalDate::compareTo) - .orElse(baseDate); - - LocalDate targetDate = minDate.plusDays(dayOffset); - - // 5. 更新所有detail记录 - for (MartialScheduleDetail detail : details) { - detail.setVenueId(dto.getTargetVenueId()); - detail.setVenueName(targetVenue.getVenueName()); - detail.setScheduleDate(targetDate); - detail.setTimeSlot(timeSlot); - detail.setTimeSlotIndex(dto.getTargetTimeSlotIndex()); - scheduleDetailMapper.updateById(detail); - } - - return true; + // Delegated to ScheduleDispatchService + return scheduleDispatchService.moveScheduleGroup(dto); } + @Override public org.springblade.modules.martial.pojo.vo.DispatchDataVO getDispatchData(Long competitionId, Long venueId, Integer timeSlotIndex) { // Delegated to ScheduleDispatchService diff --git a/src/main/java/org/springblade/modules/martial/service/impl/ScheduleDispatchServiceImpl.java b/src/main/java/org/springblade/modules/martial/service/impl/ScheduleDispatchServiceImpl.java index 8b0cf16..9c50668 100644 --- a/src/main/java/org/springblade/modules/martial/service/impl/ScheduleDispatchServiceImpl.java +++ b/src/main/java/org/springblade/modules/martial/service/impl/ScheduleDispatchServiceImpl.java @@ -7,15 +7,19 @@ import org.springblade.modules.martial.mapper.*; import org.springblade.modules.martial.pojo.entity.MartialScheduleDetail; import org.springblade.modules.martial.pojo.entity.MartialScheduleGroup; import org.springblade.modules.martial.pojo.entity.MartialScheduleParticipant; +import org.springblade.modules.martial.pojo.entity.MartialVenue; import org.springblade.modules.martial.pojo.dto.*; import org.springblade.modules.martial.pojo.vo.*; import org.springblade.modules.martial.service.IScheduleDispatchService; +import org.springblade.modules.martial.service.IMartialVenueService; import org.springframework.stereotype.Service; import org.springframework.cache.annotation.CacheEvict; import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; +import java.time.LocalDate; +import java.util.Objects; @Slf4j @Service @@ -25,6 +29,7 @@ public class ScheduleDispatchServiceImpl implements IScheduleDispatchService { private final MartialScheduleGroupMapper scheduleGroupMapper; private final MartialScheduleParticipantMapper scheduleParticipantMapper; private final MartialScheduleDetailMapper scheduleDetailMapper; + private final IMartialVenueService venueService; @Override public org.springblade.modules.martial.pojo.vo.DispatchDataVO getDispatchData(Long competitionId, Long venueId, Integer timeSlotIndex) { @@ -181,4 +186,65 @@ public class ScheduleDispatchServiceImpl implements IScheduleDispatchService { return true; } + @Override + @CacheEvict(value = "scheduleResult", allEntries = true) + @Transactional(rollbackFor = Exception.class) + public boolean moveScheduleGroup(MoveScheduleGroupDTO dto) { + // 1. Query group information + MartialScheduleGroup group = scheduleGroupMapper.selectById(dto.getGroupId()); + if (group == null) { + throw new RuntimeException("分组不存在"); + } + + // 2. Query detail records for this group + List details = scheduleDetailMapper.selectList( + new QueryWrapper() + .eq("schedule_group_id", dto.getGroupId()) + .eq("is_deleted", 0) + ); + + if (details.isEmpty()) { + throw new RuntimeException("分组详情不存在"); + } + + // 3. Query target venue information + MartialVenue targetVenue = venueService.getById(dto.getTargetVenueId()); + if (targetVenue == null) { + throw new RuntimeException("目标场地不存在"); + } + + // 4. Calculate date and time based on time slot index + // Assumption: 0=Day1 AM, 1=Day1 PM, 2=Day2 AM, 3=Day2 PM... + int dayOffset = dto.getTargetTimeSlotIndex() / 2; // 2 slots per day + boolean isAfternoon = dto.getTargetTimeSlotIndex() % 2 == 1; + String timeSlot = isAfternoon ? "13:30" : "08:30"; + + // Get base date from first detail + LocalDate baseDate = details.get(0).getScheduleDate(); + if (baseDate == null) { + throw new RuntimeException("无法确定赛事起始日期"); + } + + // Calculate target date + LocalDate minDate = details.stream() + .map(MartialScheduleDetail::getScheduleDate) + .filter(Objects::nonNull) + .min(LocalDate::compareTo) + .orElse(baseDate); + + LocalDate targetDate = minDate.plusDays(dayOffset); + + // 5. Update all detail records + for (MartialScheduleDetail detail : details) { + detail.setVenueId(dto.getTargetVenueId()); + detail.setVenueName(targetVenue.getVenueName()); + detail.setScheduleDate(targetDate); + detail.setTimeSlot(timeSlot); + detail.setTimeSlotIndex(dto.getTargetTimeSlotIndex()); + scheduleDetailMapper.updateById(detail); + } + + return true; + } + }