| | |
| | | package com.yuanchu.mom; |
| | | |
| | | import com.yuanchu.mom.service.PerformanceShiftService; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import java.util.Map; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.time.temporal.WeekFields; |
| | | import java.util.Locale; |
| | | |
| | | |
| | | @SpringBootTest |
| | | class SystemRunApplicationTest { |
| | | |
| | | private static String fileName = "D:\\" + System.currentTimeMillis() + ".xlsx"; |
| | | |
| | | @Autowired |
| | | private PerformanceShiftService performanceShiftService; |
| | | |
| | | @Test |
| | | void contextLoads() { |
| | | Map<Object, Object> header = performanceShiftService.exportToExcel("2024-05-04 00:00:00", null, null); |
| | | |
| | | // EasyExcel.write(fileName) |
| | | // .head(header) |
| | | // // 合并策略:合并相同数据的行。第一个参数表示从哪一行开始进行合并,由于表头占了两行,因此从第2行开始(索引从0开始) |
| | | // // 第二个参数是指定哪些列要进行合并 |
| | | //// .registerWriteHandler(new MergeSameRowsStrategy(2, new int[]{0, 1, 2, 3, 8, 9})) |
| | | // // 注意:需要先调用registerWriteHandler()再调用sheet()方法才能使合并策略生效!!! |
| | | // .sheet("模板") |
| | | // .doWrite(data()); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); |
| | | String a = "09:00:00"; |
| | | String b = "17:00:00"; |
| | | LocalTime now = LocalTime.now(); |
| | | LocalTime startTime = LocalTime.parse(a, formatter); |
| | | LocalTime endTime = LocalTime.parse(b, formatter); |
| | | |
| | | // 检查当前时间是否在范围内(包括边界) |
| | | boolean isWithinRange = !now.isBefore(startTime) && !now.isAfter(endTime); |
| | | System.out.println(isWithinRange); |
| | | } |
| | | |
| | | |
| | | } |