From 17c7e460e0664ef30b34b6a6af8ad72a075d401c Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期一, 24 三月 2025 15:05:48 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java | 82 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java b/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java
index af60537..4eafbf4 100644
--- a/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java
+++ b/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java
@@ -1,14 +1,36 @@
package com.yuanchu.mom.backup;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.yuanchu.mom.dto.PerformanceShiftAddDto;
+import com.yuanchu.mom.mapper.DepartmentLimsMapper;
+import com.yuanchu.mom.mapper.EnumMapper;
+import com.yuanchu.mom.pojo.DepartmentLims;
+import com.yuanchu.mom.pojo.Enums;
+import com.yuanchu.mom.pojo.PerformanceShift;
+import com.yuanchu.mom.pojo.User;
+import com.yuanchu.mom.service.DepartmentLimsService;
+import com.yuanchu.mom.service.EnumService;
+import com.yuanchu.mom.service.PerformanceShiftService;
+import com.yuanchu.mom.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+import javax.annotation.Resource;
import java.io.*;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.temporal.TemporalAdjusters;
+import java.time.temporal.WeekFields;
import java.util.Date;
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
@Component
@EnableScheduling
@@ -55,11 +77,23 @@
@Value("${backup.mysqldump}")
private String mysqldump;
+ @Resource
+ private PerformanceShiftService performanceShiftService;
+
+ @Resource
+ private EnumService enumService;
+
+ @Resource
+ private UserService userService;
+
+ @Resource
+ private DepartmentLimsMapper departmentLimsMapper;
+
/**
* 姣忓ぉ鏅氫笂23鐐�05绉掓墽琛� 銆� 0 0 4 1/1 * ? 銆�
* 娴嬭瘯 20 绉掍竴娆°�� 0/20 * * * * ? 銆慇Scheduled(cron = "5 * 23 * * ?")
*/
- @Scheduled(cron = "5 0 23 * * ?")
+ //@Scheduled(cron = "0/20 * * * * ?")
private void configureTasks() {
log.info("銆愬浠芥暟鎹簱銆�--START");
String dbUrl2 = dbUrl.replace("jdbc:mysql://", "");
@@ -149,7 +183,7 @@
* 姣忓ぉ鏅氫笂23鐐�0鍒�10绉掓墽琛� 銆� 0 0 4 1/1 * ? 銆�
* 娴嬭瘯 20 绉掍竴娆°�� 0/20 * * * * ? 銆�
*/
- @Scheduled(cron = "6 0 23 * * ?")
+// @Scheduled(cron = "6 0 23 * * ?")
private void TimerDeleteFile(){
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("d");
@@ -171,6 +205,50 @@
}
}
+
+ /**
+ * 瀹氭椂浠诲姟,姣忎釜鏈�1鍙风殑00:00:00缁欎笅涓�涓湀鎺掔彮
+ * 缁欐瘡涓汉閮借繘琛屾帓鐝�(榛樿鏃╃彮)
+ */
+ @Scheduled(cron = "0 0 0 1 * ?")
+ //@Scheduled(cron = "0/20 * * * * ?")
+ private void timerCreateSchedule(){
+ System.out.println("寮�濮嬬粰姣忎釜浜鸿繘琛屾帓鐝�,榛樿鏃╃彮======start");
+ // TODO 缁欐瘡涓汉閮借繘琛屾帓鐝�(榛樿鏃╃彮)
+ PerformanceShiftAddDto performanceShiftAddDto = new PerformanceShiftAddDto();
+ //鐝--鏃�(鏌ヨ瀛楀吀)
+ List<Enums> shiftType = enumService.selectEnumByCategory("鐝绫诲瀷");
+ List<String> collect = shiftType.stream().filter(enums -> enums.getLabel().equals("鏃�")).map(enums -> enums.getValue()).collect(Collectors.toList());
+ performanceShiftAddDto.setShift(collect.get(0));
+ //浜哄憳--(departlims琛ㄧ殑涓や釜瀹為獙瀹ょ殑浜�)
+ String userIds = userService.getUser().stream().map(user -> user.getId().toString()).distinct().collect(Collectors.joining(","));
+ performanceShiftAddDto.setUserId(userIds);
+ //鍛ㄦ--褰撴湀鎵�鏈�
+ // 鑾峰彇褰撳墠鏃ユ湡
+ LocalDate today = LocalDate.now().plusMonths(1);
+ // 鑾峰彇鏈湀鐨勭涓�澶╁拰鏈�鍚庝竴澶�
+ LocalDate firstDayOfMonth = today.with(TemporalAdjusters.firstDayOfMonth());
+ LocalDate lastDayOfMonth = today.with(TemporalAdjusters.lastDayOfMonth());
+ // 鑾峰彇鍛ㄥ瓧娈典俊鎭紙鏍规嵁鍖哄煙璁剧疆锛�
+ WeekFields weekFields = WeekFields.of(Locale.getDefault());
+ // 鑾峰彇鏈湀绗竴澶╃殑鍛ㄤ竴
+ LocalDate startOfWeek = firstDayOfMonth.with(TemporalAdjusters.previousOrSame(weekFields.getFirstDayOfWeek()));
+ // 閬嶅巻鏈湀鎵�鏈夊ぉ鏁帮紝鎵惧嚭姣忓懆鐨勭涓�澶╁拰鏈�鍚庝竴澶�
+ LocalDate endOfWeek;
+ while (startOfWeek.isBefore(firstDayOfMonth.plusMonths(1))) {
+ endOfWeek = startOfWeek.plusDays(6);
+ LocalDateTime startDateTime = LocalDateTime.of(startOfWeek, LocalTime.MIDNIGHT);
+ LocalDateTime endDateTime = LocalDateTime.of(endOfWeek, LocalTime.MIDNIGHT);
+ System.out.println("Week starts on " + startDateTime + " and ends on " + endDateTime);
+ performanceShiftAddDto.setStartWeek(startDateTime);
+ performanceShiftAddDto.setEndWeek(endDateTime);
+ performanceShiftService.performanceShiftAdd(performanceShiftAddDto);
+ startOfWeek = startOfWeek.plusWeeks(1);
+ }
+
+ System.out.println("鎺掔彮缁撴潫======end");
+ }
+
/**
* 鍒ゆ柇鏂囦欢鏄惁瀛樺湪锛屼笉瀛樺湪鍒涘缓
*/
--
Gitblit v1.9.3