Crunchy
2024-05-13 35da9191297752452f7ab60ff9bc3eed515dfeec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
 
 
@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);
    }
}