From d17d4d1ac98865d2a71b4f24771b7b76e0839ed3 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 10 四月 2026 14:08:41 +0800
Subject: [PATCH] yys 1.设备区域 2.设备巡检,维保,保养多选 3.数采

---
 src/main/java/com/ruoyi/inspectiontask/service/impl/TimingTaskServiceImpl.java |  286 +++++++++++++++++++++++++++------------------------------
 1 files changed, 136 insertions(+), 150 deletions(-)

diff --git a/src/main/java/com/ruoyi/inspectiontask/service/impl/TimingTaskServiceImpl.java b/src/main/java/com/ruoyi/inspectiontask/service/impl/TimingTaskServiceImpl.java
index 6607d68..f23a6a4 100644
--- a/src/main/java/com/ruoyi/inspectiontask/service/impl/TimingTaskServiceImpl.java
+++ b/src/main/java/com/ruoyi/inspectiontask/service/impl/TimingTaskServiceImpl.java
@@ -6,6 +6,10 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.device.mapper.DeviceAreaMapper;
+import com.ruoyi.device.mapper.DeviceLedgerMapper;
+import com.ruoyi.device.pojo.DeviceArea;
+import com.ruoyi.device.pojo.DeviceLedger;
 import com.ruoyi.inspectiontask.dto.TimingTaskDto;
 import com.ruoyi.inspectiontask.mapper.InspectionTaskMapper;
 import com.ruoyi.inspectiontask.mapper.TimingTaskMapper;
@@ -19,9 +23,23 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.time.*;
+import java.time.DayOfWeek;
+import java.time.DateTimeException;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Year;
+import java.time.YearMonth;
 import java.time.format.DateTimeFormatter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -44,35 +62,34 @@
     @Autowired
     private SysUserMapper sysUserMapper;
 
+    @Autowired
+    private DeviceLedgerMapper deviceLedgerMapper;
+
+    @Autowired
+    private DeviceAreaMapper deviceAreaMapper;
 
     @Override
     public IPage<TimingTaskDto> selectTimingTaskList(Page<TimingTask> page, TimingTask timingTask) {
-        // 1. 鍏堝垎椤垫煡璇㈠畾鏃朵换鍔℃暟鎹�
-        // 鏋勫缓鏌ヨ鏉′欢
         LambdaQueryWrapper<TimingTask> queryWrapper = new LambdaQueryWrapper<>();
         if (StringUtils.isNotBlank(timingTask.getTaskName())) {
             queryWrapper.like(TimingTask::getTaskName, timingTask.getTaskName());
         }
+        if (timingTask.getAreaId() != null) {
+            queryWrapper.eq(TimingTask::getAreaId, timingTask.getAreaId());
+        }
         IPage<TimingTask> taskPage = timingTaskMapper.selectPage(page, queryWrapper);
-
-        // 2. 濡傛灉娌℃湁鏁版嵁锛岀洿鎺ヨ繑鍥炵┖鍒嗛〉
         if (taskPage.getRecords().isEmpty()) {
             return new Page<>(taskPage.getCurrent(), taskPage.getSize(), taskPage.getTotal());
         }
 
-        // 3. 鏀堕泦鎵�鏈夐渶瑕佹煡璇㈢殑鐢ㄦ埛ID
         Set<Long> userIds = new HashSet<>();
-
-        // 鏀堕泦鐧昏浜篒D
         taskPage.getRecords().forEach(task -> {
             if (task.getRegistrantId() != null) {
                 userIds.add(task.getRegistrantId());
             }
-        });
-
-        // 鏀堕泦宸℃浜篒D锛堝涓狪D浠ラ�楀彿鍒嗛殧锛�
-        taskPage.getRecords().forEach(task -> {
-            task.setDateStr(task.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+            if (task.getCreateTime() != null) {
+                task.setDateStr(task.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+            }
             if (StringUtils.isNotBlank(task.getInspectorIds())) {
                 Arrays.stream(task.getInspectorIds().split(","))
                         .filter(StringUtils::isNotBlank)
@@ -81,25 +98,27 @@
             }
         });
 
-        // 4. 鎵归噺鏌ヨ鐢ㄦ埛淇℃伅
         Map<Long, String> userNickNameMap = new HashMap<>();
         if (!userIds.isEmpty()) {
-            List<SysUser> users = sysUserMapper.selectUserByIds((new ArrayList<>(userIds)));
+            List<SysUser> users = sysUserMapper.selectUserByIds(new ArrayList<>(userIds));
             users.forEach(user -> userNickNameMap.put(user.getUserId(), user.getNickName()));
         }
 
-        // 5. 杞崲涓篋TO
+        Map<Long, String> areaNameMap = deviceAreaMapper.selectBatchIds(taskPage.getRecords().stream()
+                        .map(TimingTask::getAreaId)
+                        .filter(Objects::nonNull)
+                        .distinct()
+                        .collect(Collectors.toList()))
+                .stream()
+                .collect(Collectors.toMap(DeviceArea::getId, DeviceArea::getAreaName, (left, right) -> left, HashMap::new));
+
         List<TimingTaskDto> dtoList = taskPage.getRecords().stream().map(task -> {
             TimingTaskDto dto = new TimingTaskDto();
-            // 澶嶅埗鍩烘湰灞炴��
             BeanUtils.copyProperties(task, dto);
-
-            // 璁剧疆鐧昏浜烘樀绉�
             if (task.getRegistrantId() != null) {
                 dto.setRegistrant(userNickNameMap.getOrDefault(task.getRegistrantId(), "鏈煡鐢ㄦ埛"));
             }
-
-            // 璁剧疆宸℃浜烘樀绉板垪琛�
+            dto.setAreaName(areaNameMap.get(task.getAreaId()));
             if (StringUtils.isNotBlank(task.getInspectorIds())) {
                 List<String> inspectorNickNames = new ArrayList<>();
                 for (String idStr : task.getInspectorIds().split(",")) {
@@ -110,11 +129,9 @@
                 }
                 dto.setInspector(inspectorNickNames);
             }
-
             return dto;
         }).collect(Collectors.toList());
 
-        // 6. 鏋勫缓杩斿洖鐨勫垎椤靛璞�
         Page<TimingTaskDto> resultPage = new Page<>(taskPage.getCurrent(), taskPage.getSize(), taskPage.getTotal());
         resultPage.setRecords(dtoList);
         return resultPage;
@@ -125,58 +142,90 @@
     public int addOrEditTimingTask(TimingTaskDto timingTaskDto) throws SchedulerException {
         TimingTask timingTask = new TimingTask();
         BeanUtils.copyProperties(timingTaskDto, timingTask);
-        // 1. 瑙f瀽瀛楃涓蹭负 LocalDate锛堝彧鍖呭惈骞存湀鏃ワ級
+        prepareTimingTask(timingTask);
+
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate localDate = LocalDate.now();
-        if(StringUtils.isNotEmpty(timingTaskDto.getDateStr())){
+        if (StringUtils.isNotEmpty(timingTaskDto.getDateStr())) {
             localDate = LocalDate.parse(timingTaskDto.getDateStr(), formatter);
         }
-        // 2. 鑾峰彇褰撳墠绯荤粺鐨� LocalTime锛堝寘鍚椂鍒嗙锛�
         LocalTime currentTime = LocalTime.now();
+        timingTask.setCreateTime(LocalDateTime.of(localDate, currentTime));
 
-        // 3. 鍚堝苟 LocalDate 鍜屽綋鍓� LocalTime 涓� LocalDateTime
-        LocalDateTime localDateTime = LocalDateTime.of(localDate, currentTime);
-        timingTask.setCreateTime(localDateTime);
-        // 璁剧疆鍒涘缓浜轰俊鎭拰榛樿鍊�
         if (Objects.isNull(timingTaskDto.getId())) {
             timingTask.setRegistrationDate(LocalDate.now());
             timingTask.setActive(true);
-
-            // 璁$畻棣栨鎵ц鏃堕棿
-            LocalDateTime firstExecutionTime = calculateFirstExecutionTime(timingTask);
-            timingTask.setNextExecutionTime(firstExecutionTime);
+            timingTask.setNextExecutionTime(calculateFirstExecutionTime(timingTask));
             int result = timingTaskMapper.insert(timingTask);
             if (result > 0) {
-                // 鏂板鎴愬姛鍚庢坊鍔犲埌璋冨害鍣�
                 timingTaskScheduler.scheduleTimingTask(timingTask);
             }
             return result;
-        } else {
-
-
-            int result = timingTaskMapper.updateById(timingTask);
-            if (result > 0) {
-                // 鏇存柊鎴愬姛鍚庨噸鏂拌皟搴︿换鍔�
-                timingTaskScheduler.rescheduleTimingTask(timingTask);
-            }
-            return result;
         }
+
+        int result = timingTaskMapper.updateById(timingTask);
+        if (result > 0) {
+            timingTaskScheduler.rescheduleTimingTask(timingTask);
+        }
+        return result;
+    }
+
+    private void prepareTimingTask(TimingTask timingTask) {
+        Long[] selectedTaskIds = timingTask.getTaskIds();
+        if ((selectedTaskIds == null || selectedTaskIds.length == 0) && timingTask.getTaskId() != null) {
+            selectedTaskIds = new Long[]{timingTask.getTaskId().longValue()};
+        }
+        if (selectedTaskIds == null || selectedTaskIds.length == 0) {
+            timingTask.setTaskIdsStr(null);
+            return;
+        }
+
+        List<Long> deviceIds = Arrays.stream(selectedTaskIds)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+        if (deviceIds.isEmpty()) {
+            timingTask.setTaskIdsStr(null);
+            return;
+        }
+
+        List<DeviceLedger> devices = deviceLedgerMapper.selectBatchIds(deviceIds);
+        Map<Long, DeviceLedger> deviceMap = devices.stream()
+                .collect(Collectors.toMap(DeviceLedger::getId, device -> device, (left, right) -> left, LinkedHashMap::new));
+
+        List<Long> validDeviceIds = deviceIds.stream()
+                .filter(deviceMap::containsKey)
+                .collect(Collectors.toList());
+        if (validDeviceIds.isEmpty()) {
+            throw new IllegalArgumentException("鎵�閫夎澶囦笉瀛樺湪");
+        }
+
+        timingTask.setTaskIds(validDeviceIds.toArray(new Long[0]));
+        timingTask.setTaskIdsStr(validDeviceIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
+        timingTask.setTaskId(validDeviceIds.get(0).intValue());
+        if (timingTask.getAreaId() == null) {
+            DeviceLedger firstDevice = deviceMap.get(validDeviceIds.get(0));
+            if (firstDevice != null) {
+                timingTask.setAreaId(firstDevice.getAreaId());
+            }
+        }
+        timingTask.setTaskName(validDeviceIds.stream()
+                .map(deviceMap::get)
+                .filter(Objects::nonNull)
+                .map(DeviceLedger::getDeviceName)
+                .filter(StringUtils::isNotBlank)
+                .collect(Collectors.joining(",")));
     }
 
     public LocalDateTime calculateFirstExecutionTime(TimingTask task) {
-        // 鏍规嵁棰戠巼绫诲瀷鍜岃鎯呰绠楅娆℃墽琛屾椂闂�
         String frequencyType = task.getFrequencyType();
         if ("DAILY".equals(frequencyType)) {
-            // 濡傛灉鏄瘡澶╂墽琛岋紝璁$畻浠婂ぉ鎴栨槑澶╃殑鍏蜂綋鏃堕棿
             return calculateDailyFirstExecution(task.getFrequencyDetail());
         } else if ("WEEKLY".equals(frequencyType)) {
-            // 濡傛灉鏄瘡鍛ㄦ墽琛岋紝璁$畻涓嬪懆鐨勫叿浣撴槦鏈熷嚑
             return calculateWeeklyFirstExecution(task.getFrequencyDetail());
         } else if ("MONTHLY".equals(frequencyType)) {
-            // 濡傛灉鏄瘡鏈堟墽琛岋紝璁$畻涓嬩釜鏈堢殑鍏蜂綋鏃ユ湡
             return calculateMonthlyFirstExecution(task.getFrequencyDetail());
         } else if ("QUARTERLY".equals(frequencyType)) {
-            // 鑷畾涔夐鐜囷紝濡傛瘡灏忔椂銆佹瘡30鍒嗛挓绛�
             return calculateCustomFirstExecution(task.getFrequencyDetail());
         } else {
             throw new IllegalArgumentException("涓嶆敮鎸佺殑棰戠巼绫诲瀷: " + task.getFrequencyType());
@@ -184,17 +233,14 @@
     }
 
     private LocalDateTime calculateDailyFirstExecution(String frequencyDetail) {
-        // frequencyDetail鍙兘鏄叿浣撴椂闂达紝濡� "14:30"
         LocalTime executionTime = LocalTime.parse(frequencyDetail);
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime todayExecution = LocalDateTime.of(now.toLocalDate(), executionTime);
-
-        // 濡傛灉浠婂ぉ鐨勬椂闂村凡杩囷紝鍒欏畨鎺掓槑澶╂墽琛�
         return now.isBefore(todayExecution) ? todayExecution : todayExecution.plusDays(1);
     }
 
-    // 鏄犲皠鏄熸湡绠�鍐欎笌DayOfWeek
     private static final Map<String, DayOfWeek> WEEK_DAY_MAP = new HashMap<>();
+
     static {
         WEEK_DAY_MAP.put("MON", DayOfWeek.MONDAY);
         WEEK_DAY_MAP.put("TUE", DayOfWeek.TUESDAY);
@@ -206,47 +252,36 @@
     }
 
     private LocalDateTime calculateWeeklyFirstExecution(String frequencyDetail) {
-        // 瑙f瀽杈撳叆鍙傛暟
         String[] parts = frequencyDetail.split(",");
         if (parts.length != 2) {
-            throw new IllegalArgumentException("鍙傛暟鏍煎紡閿欒锛屽簲涓�'MON,13:43'鏍煎紡");
+            throw new IllegalArgumentException("鍙傛暟鏍煎紡閿欒锛屽簲涓� MON,13:43");
         }
 
         String weekDayStr = parts[0].trim();
         String timeStr = parts[1].trim();
-
-        // 鑾峰彇瀵瑰簲鐨勬槦鏈熷嚑
         DayOfWeek targetDay = WEEK_DAY_MAP.get(weekDayStr);
         if (targetDay == null) {
-            throw new IllegalArgumentException("鏃犳晥鐨勬槦鏈熺畝鍐�: " + weekDayStr);
+            throw new IllegalArgumentException("鏃犳晥鐨勬槦鏈�: " + weekDayStr);
         }
 
-        // 瑙f瀽鏃堕棿
         LocalTime targetTime = LocalTime.parse(timeStr, DateTimeFormatter.ofPattern("HH:mm"));
-
-        // 鑾峰彇褰撳墠鏃堕棿
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime targetDateTime = now.with(targetDay).with(targetTime);
-
-        // 濡傛灉璁$畻鍑虹殑鏃堕棿鍦ㄥ綋鍓嶆椂闂翠箣鍓嶏紝鍒欏姞涓�鍛�
         if (targetDateTime.isBefore(now)) {
             targetDateTime = targetDateTime.plusWeeks(1);
         }
-
         return targetDateTime;
     }
 
     private LocalDateTime calculateMonthlyFirstExecution(String frequencyDetail) {
-        // 瑙f瀽杈撳叆鍙傛暟
         String[] parts = frequencyDetail.split(",");
         if (parts.length != 2) {
-            throw new IllegalArgumentException("鍙傛暟鏍煎紡閿欒锛屽簲涓�'03,17:00'鏍煎紡");
+            throw new IllegalArgumentException("鍙傛暟鏍煎紡閿欒锛屽簲涓� 03,17:00");
         }
 
         String dayStr = parts[0].trim();
         String timeStr = parts[1].trim();
 
-        // 瑙f瀽鏃ユ湡
         int dayOfMonth;
         try {
             dayOfMonth = Integer.parseInt(dayStr);
@@ -254,12 +289,10 @@
             throw new IllegalArgumentException("鏃犳晥鐨勬棩鏈熸牸寮�: " + dayStr, e);
         }
 
-        // 楠岃瘉鏃ユ湡鏈夋晥鎬э紙1-31涔嬮棿锛�
         if (dayOfMonth < 1 || dayOfMonth > 31) {
-            throw new IllegalArgumentException("鏃ユ湡蹇呴』鍦�1-31涔嬮棿: " + dayOfMonth);
+            throw new IllegalArgumentException("鏃ユ湡蹇呴』鍦� 1-31 涔嬮棿: " + dayOfMonth);
         }
 
-        // 瑙f瀽鏃堕棿
         LocalTime targetTime;
         try {
             targetTime = LocalTime.parse(timeStr, DateTimeFormatter.ofPattern("HH:mm"));
@@ -267,32 +300,18 @@
             throw new IllegalArgumentException("鏃犳晥鐨勬椂闂存牸寮�: " + timeStr, e);
         }
 
-        // 鑾峰彇褰撳墠鏃堕棿
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime targetDateTime = now.withDayOfMonth(dayOfMonth).with(targetTime);
-
-        // 妫�鏌ユ棩鏈熸槸鍚﹁鑷姩璋冩暣锛堝31鏃ュ湪灏忔湀浼氳璋冩暣锛�
         boolean isDateAdjusted = targetDateTime.getDayOfMonth() != dayOfMonth;
-
-        // 濡傛灉鐩爣鏃堕棿鍦ㄥ綋鍓嶆椂闂翠箣鍓嶏紝鎴栬�呮棩鏈熻绯荤粺鑷姩璋冩暣浜�
         if (targetDateTime.isBefore(now) || isDateAdjusted) {
-            // 璁$畻涓嬩釜鏈堢殑鏃ユ湡
             LocalDateTime nextMonth = now.plusMonths(1);
-            // 灏濊瘯璁剧疆涓嬩釜鏈堢殑鐩爣鏃ユ湡
             LocalDateTime nextMonthTarget = nextMonth.withDayOfMonth(dayOfMonth).with(targetTime);
-
-            // 濡傛灉涓嬩釜鏈堢殑鏃ユ湡涔熻璋冩暣浜嗭紝灏辩敤涓嬩釜鏈堢殑鏈�鍚庝竴澶�
             if (nextMonthTarget.getDayOfMonth() != dayOfMonth) {
-                // 姝g‘鑾峰彇涓嬩釜鏈堢殑鏈�鍚庝竴澶╋紙淇isLeapYear璋冪敤闂锛�
-                int lastDayOfMonth = nextMonth.getMonth().length(
-                        Year.of(nextMonth.getYear()).isLeap()
-                );
+                int lastDayOfMonth = nextMonth.getMonth().length(Year.of(nextMonth.getYear()).isLeap());
                 nextMonthTarget = nextMonth.withDayOfMonth(lastDayOfMonth).with(targetTime);
             }
-
             targetDateTime = nextMonthTarget;
         }
-
         return targetDateTime;
     }
 
@@ -308,24 +327,16 @@
             throw new RuntimeException("瀹氭椂浠诲姟涓嶅瓨鍦紝ID: " + taskId);
         }
 
-        // 鏇存柊鏈�鍚庢墽琛屾椂闂翠负褰撳墠鏃堕棿
         task.setLastExecutionTime(LocalDateTime.now());
-
-        // 璁$畻涓嬫鎵ц鏃堕棿
         LocalDateTime nextExecutionTime = calculateNextExecutionTime(
                 task.getFrequencyType(),
                 task.getFrequencyDetail(),
                 LocalDateTime.now()
         );
         task.setNextExecutionTime(nextExecutionTime);
-
-        // 鏇存柊鏁版嵁搴�
         timingTaskMapper.updateById(task);
     }
 
-    /**
-     * 璁$畻涓嬫鎵ц鏃堕棿
-     */
     private LocalDateTime calculateNextExecutionTime(String frequencyType,
                                                      String frequencyDetail,
                                                      LocalDateTime currentTime) {
@@ -347,86 +358,54 @@
         }
     }
 
-    /**
-     * 璁$畻姣忔棩浠诲姟鐨勪笅娆℃墽琛屾椂闂�
-     */
     private LocalDateTime calculateDailyNextTime(String timeStr, LocalDateTime current) {
-        LocalTime executionTime = LocalTime.parse(timeStr); // 瑙f瀽鏍煎紡 "HH:mm"
+        LocalTime executionTime = LocalTime.parse(timeStr);
         LocalDateTime nextTime = LocalDateTime.of(current.toLocalDate(), executionTime);
-
-        // 濡傛灉浠婂ぉ鐨勬椂闂村凡杩囷紝鍒欏畨鎺掓槑澶�
         return current.isBefore(nextTime) ? nextTime : nextTime.plusDays(1);
     }
 
-    /**
-     * 璁$畻姣忓懆浠诲姟鐨勪笅娆℃墽琛屾椂闂�
-     */
     private LocalDateTime calculateWeeklyNextTime(String detail, LocalDateTime current) {
         String[] parts = detail.split(",");
-        String dayOfWeekStr = parts[0];  // 濡� "MON" 鎴� "MON|WED|FRI"
-        LocalTime time = LocalTime.parse(parts[1]); // 鏃堕棿閮ㄥ垎
-
-        // 瑙f瀽鏄熸湡鍑�(鏀寔澶氫釜鏄熸湡)
+        String dayOfWeekStr = parts[0];
+        LocalTime time = LocalTime.parse(parts[1]);
         Set<DayOfWeek> targetDays = parseDayOfWeeks(dayOfWeekStr);
 
-        // 浠庡綋鍓嶆椂闂村紑濮嬫壘涓嬩竴涓鍚堟潯浠剁殑鏄熸湡鍑�
         LocalDateTime nextTime = current;
         while (true) {
             nextTime = nextTime.plusDays(1);
             if (targetDays.contains(nextTime.getDayOfWeek())) {
                 return LocalDateTime.of(nextTime.toLocalDate(), time);
             }
-
-            // 闃叉鏃犻檺寰幆(鐞嗚涓婁笉浼氬彂鐢�)
             if (nextTime.isAfter(current.plusYears(1))) {
                 throw new RuntimeException("鏃犳硶鎵惧埌涓嬫鎵ц鏃堕棿");
             }
         }
     }
 
-    /**
-     * 璁$畻姣忔湀浠诲姟鐨勪笅娆℃墽琛屾椂闂�
-     */
     private LocalDateTime calculateMonthlyNextTime(String detail, LocalDateTime current) {
         String[] parts = detail.split(",");
         int dayOfMonth = Integer.parseInt(parts[0]);
         LocalTime time = LocalTime.parse(parts[1]);
-
-        // 浠庝笅涓湀寮�濮嬭绠�
-        LocalDateTime nextTime = current.plusMonths(1)
+        return current.plusMonths(1)
                 .withDayOfMonth(Math.min(dayOfMonth, current.plusMonths(1).toLocalDate().lengthOfMonth()))
                 .with(time);
-
-        return nextTime;
     }
 
-    /**
-     * 璁$畻姣忓搴︿换鍔$殑涓嬫鎵ц鏃堕棿
-     */
     private LocalDateTime calculateQuarterlyNextTime(String detail, LocalDateTime current) {
         String[] parts = detail.split(",");
-        int quarterMonth = Integer.parseInt(parts[0]); // 1=绗�1涓湀锛�2=绗�2涓湀锛�3=绗�3涓湀
+        int quarterMonth = Integer.parseInt(parts[0]);
         int dayOfMonth = Integer.parseInt(parts[1]);
         LocalTime time = LocalTime.parse(parts[2]);
 
-        // 璁$畻褰撳墠瀛e害
-        int currentQuarter = (current.getMonthValue() - 1) / 3 + 1;
         int currentMonthInQuarter = (current.getMonthValue() - 1) % 3 + 1;
-
         YearMonth targetYearMonth;
         if (currentMonthInQuarter < quarterMonth) {
-            // 鏈搴﹀唴杩樻湁鎵ц鏈轰細
-            targetYearMonth = YearMonth.from(current)
-                    .plusMonths(quarterMonth - currentMonthInQuarter);
+            targetYearMonth = YearMonth.from(current).plusMonths(quarterMonth - currentMonthInQuarter);
         } else {
-            // 闇�瑕佸埌涓嬩釜瀛e害
-            targetYearMonth = YearMonth.from(current)
-                    .plusMonths(3 - currentMonthInQuarter + quarterMonth);
+            targetYearMonth = YearMonth.from(current).plusMonths(3 - currentMonthInQuarter + quarterMonth);
         }
 
-        // 澶勭悊鏈堟湯鏃ユ湡
         int adjustedDay = Math.min(dayOfMonth, targetYearMonth.lengthOfMonth());
-
         return LocalDateTime.of(
                 targetYearMonth.getYear(),
                 targetYearMonth.getMonthValue(),
@@ -436,40 +415,47 @@
         );
     }
 
-    /**
-     * 瑙f瀽鏄熸湡鍑犲瓧绗︿覆
-     */
     private Set<DayOfWeek> parseDayOfWeeks(String dayOfWeekStr) {
         Set<DayOfWeek> days = new HashSet<>();
         String[] dayStrs = dayOfWeekStr.split("\\|");
-
         for (String dayStr : dayStrs) {
             switch (dayStr) {
-                case "MON": days.add(DayOfWeek.MONDAY); break;
-                case "TUE": days.add(DayOfWeek.TUESDAY); break;
-                case "WED": days.add(DayOfWeek.WEDNESDAY); break;
-                case "THU": days.add(DayOfWeek.THURSDAY); break;
-                case "FRI": days.add(DayOfWeek.FRIDAY); break;
-                case "SAT": days.add(DayOfWeek.SATURDAY); break;
-                case "SUN": days.add(DayOfWeek.SUNDAY); break;
-                default: throw new IllegalArgumentException("鏃犳晥鐨勬槦鏈熷嚑: " + dayStr);
+                case "MON":
+                    days.add(DayOfWeek.MONDAY);
+                    break;
+                case "TUE":
+                    days.add(DayOfWeek.TUESDAY);
+                    break;
+                case "WED":
+                    days.add(DayOfWeek.WEDNESDAY);
+                    break;
+                case "THU":
+                    days.add(DayOfWeek.THURSDAY);
+                    break;
+                case "FRI":
+                    days.add(DayOfWeek.FRIDAY);
+                    break;
+                case "SAT":
+                    days.add(DayOfWeek.SATURDAY);
+                    break;
+                case "SUN":
+                    days.add(DayOfWeek.SUNDAY);
+                    break;
+                default:
+                    throw new IllegalArgumentException("鏃犳晥鐨勬槦鏈�: " + dayStr);
             }
         }
-
         return days;
     }
-
-
 
     @Override
     public int delByIds(Long[] ids) {
         int i = timingTaskMapper.deleteBatchIds(Arrays.asList(ids));
-        if(i > 0){
+        if (i > 0) {
             for (Long id : ids) {
                 timingTaskScheduler.unscheduleTimingTask(id);
             }
         }
         return i;
     }
-
 }

--
Gitblit v1.9.3