| | |
| | | package com.yuanchu.mom; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; |
| | | import com.yuanchu.mom.service.PerformanceShiftService; |
| | | import com.yuanchu.mom.utils.StyleMonthUtils; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | 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 { |
| | | |
| | | @Autowired |
| | | private PerformanceShiftService performanceShiftService; |
| | | |
| | | private static String fileName = "D:\\" + System.currentTimeMillis() + ".xlsx"; |
| | | |
| | | @Test |
| | | void contextLoads() throws Exception { |
| | | Map<Object, Object> data = performanceShiftService.exportToMonthExcel("2024-05-01 00:00:00", null, null); |
| | | // 设置单元格样式 |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleMonthUtils.getHeadStyle(), StyleMonthUtils.getContentStyle()); |
| | | EasyExcel.write(fileName) |
| | | .head((List<List<String>>) data.get("header")) |
| | | .registerWriteHandler(horizontalCellStyleStrategy) |
| | | .sheet("月度") |
| | | .doWrite((Collection<?>) data.get("data")); |
| | | // String url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?corpid=wwa423654b975441ac&corpsecret=J3fbMJoTn3LmrWDobvS5JpU8N0TvEbGkVl8OhvIsol0"; |
| | | // String s = HttpUtil.get(url); |
| | | // System.out.println(s); |
| | | // Map<String, Object> unmarshal = JSONObject.parseObject(s, Map.class); |
| | | // String checkInRecords = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token=" + unmarshal.get("access_token"); |
| | | // String body = HttpRequest.post(checkInRecords).execute().body(); |
| | | // System.out.println(body); |
| | | void contextLoads() { |
| | | |
| | | 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); |
| | | } |
| | | } |