| | |
| | | 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.StyleYearUtils; |
| | | 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; |
| | | |
| | | |
| | | @SpringBootTest |
| | | class SystemRunApplicationTest { |
| | | |
| | | private static String fileName = "D:\\" + System.currentTimeMillis() + ".xlsx"; |
| | | |
| | | @Autowired |
| | | private PerformanceShiftService performanceShiftService; |
| | | |
| | | private static String fileName = "D:\\" + System.currentTimeMillis() + ".xlsx"; |
| | | |
| | | @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()); |
| | | void contextLoads() throws Exception { |
| | | Map<Object, Object> data = performanceShiftService.exportToYearExcel("2024-05-01 00:00:00", null, null); |
| | | // 设置单元格样式 |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleYearUtils.getHeadStyle(), StyleYearUtils.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); |
| | | } |
| | | |
| | | |
| | | } |