value
2024-05-14 e3853368e05aad326fdbb7e1057d23cb77918c7b
Merge remote-tracking branch 'origin/master'
已修改7个文件
已复制1个文件
已重命名1个文件
249 ■■■■ 文件已修改
performance-server/src/main/java/com/yuanchu/mom/controller/PerformanceShiftController.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/dto/PerformanceShiftMapDto.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/service/PerformanceShiftService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/utils/StyleMonthUtils.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/utils/StyleYearUtils.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
system-run/src/test/java/com/yuanchu/mom/SystemRunApplicationTest.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/yuanchu/mom/controller/PerformanceShiftController.java
@@ -7,7 +7,8 @@
import com.yuanchu.mom.dto.PerformanceShiftAddDto;
import com.yuanchu.mom.pojo.PerformanceShift;
import com.yuanchu.mom.service.PerformanceShiftService;
import com.yuanchu.mom.utils.StyleUtils;
import com.yuanchu.mom.utils.StyleMonthUtils;
import com.yuanchu.mom.utils.StyleYearUtils;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -64,20 +65,32 @@
    }
    @ApiOperation(value = "绩效管理-班次-导出")
    @GetMapping("update")
    public void exportToExcel(@NotNull(message = "时间不能为空!") String time, String userName, String laboratory, HttpServletResponse response) throws Exception {
        Map<Object, Object> data = performanceShiftService.exportToExcel(time, userName, laboratory);
        // è®¾ç½®å•元格样式
        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleUtils.getHeadStyle(), StyleUtils.getContentStyle());
        // ä¿å­˜åˆ°ç¬¬ä¸€ä¸ªsheet中
    @GetMapping("export")
    public void exportToExcel(@NotNull(message = "时间不能为空!") String time, String userName, String laboratory, Boolean isMonth, HttpServletResponse response) throws Exception {
        Map<Object, Object> data;
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setHeader("requestType","excel");
        response.setHeader("Access-Control-Expose-Headers", "requestType");
        EasyExcel.write(response.getOutputStream())
                .head((List<List<String>>) data.get("header"))
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // è‡ªé€‚应列宽
                .registerWriteHandler(horizontalCellStyleStrategy)
                .sheet("模板")
                .doWrite((Collection<?>) data.get("data"));
        if (!isMonth) {
            data = performanceShiftService.exportToYearExcel(time, userName, laboratory);
            // è®¾ç½®å•元格样式
            HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleYearUtils.getHeadStyle(), StyleYearUtils.getContentStyle());
            // ä¿å­˜åˆ°ç¬¬ä¸€ä¸ªsheet中
            EasyExcel.write(response.getOutputStream())
                    .head((List<List<String>>) data.get("header"))
                    .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // è‡ªé€‚应列宽
                    .registerWriteHandler(horizontalCellStyleStrategy)
                    .sheet("年度")
                    .doWrite((Collection<?>) data.get("data"));
        } else {
            data = performanceShiftService.exportToMonthExcel(time, userName, laboratory);
            // è®¾ç½®å•元格样式
            HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleMonthUtils.getHeadStyle(), StyleMonthUtils.getContentStyle());
            EasyExcel.write(response.getOutputStream())
                    .head((List<List<String>>) data.get("header"))
                    .registerWriteHandler(horizontalCellStyleStrategy)
                    .sheet("月度")
                    .doWrite((Collection<?>) data.get("data"));
        }
    }
}
performance-server/src/main/java/com/yuanchu/mom/dto/PerformanceShiftMapDto.java
@@ -16,10 +16,12 @@
    private String userId;
    private String department;
    private Map<String, Object> monthlyAttendance = new HashMap<>();
    private Map<String, Object> sidebarAnnualAttendance = new HashMap<>();;
    private List<?> list = new ArrayList<>();
    private List<Map<String, Object>> list = new ArrayList<>();
    private List<Map<Object, Object>> headerList = new ArrayList<>();
}
performance-server/src/main/java/com/yuanchu/mom/mapper/PerformanceShiftMapper.java
@@ -34,4 +34,6 @@
    IPage<Map<String, Object>> performanceShiftYear(Page<Object> page, String time, String userName, String laboratory);
    List<Map<String, Object>> performanceShiftYearList(String time, String userName, String laboratory);
    List<PerformanceShiftMapDto> performanceShiftList(String time, String userName, String laboratory);
}
performance-server/src/main/java/com/yuanchu/mom/service/PerformanceShiftService.java
@@ -26,5 +26,7 @@
    IPage<Map<String, Object>> performanceShiftPageYear(Page<Object> page, String time, String userName, String laboratory);
    Map<Object, Object> exportToExcel(String time, String userName, String laboratory) throws Exception;
    Map<Object, Object> exportToYearExcel(String time, String userName, String laboratory) throws Exception;
    Map<Object, Object> exportToMonthExcel(String time, String userName, String laboratory);
}
performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
@@ -22,6 +22,7 @@
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
@@ -100,10 +101,10 @@
        mapIPage.getRecords().forEach(i -> {
            String[] shiftTimes = i.getShiftTime().split(";");
            int totalAttendance = 0;
            List<Object> map = new ArrayList<>();
            List<Map<String, Object>> map = new ArrayList<>();
            // åˆ†å‰²æ—¥æœŸ
            for (String shiftTime : shiftTimes) {
                Map<Object, Object> hashMap = new HashMap<>();
                Map<String, Object> hashMap = new HashMap<>();
                String[] shiftTimeAndShift = shiftTime.split(":");
                for (Enums enums : shiftType) {
                    if (!i.getMonthlyAttendance().containsKey(enums.getLabel())) {
@@ -260,16 +261,58 @@
    }
    @Override
    public Map<Object, Object> exportToExcel(String time, String userName, String laboratory) throws Exception {
    public Map<Object, Object> exportToYearExcel(String time, String userName, String laboratory) throws Exception {
        Map<Object, Object> map = new HashMap<>();
        List<Enums> shiftType = enumService.selectEnumByCategory("班次类型");
        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        // å°†å­—符串时间转换为 LocalDateTime ç±»åž‹æ—¶é—´
        LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
        map.put("header", getHeader(localDateTime.getYear() + " å¹´", shiftType));
        map.put("header", getYearHeader(localDateTime.getYear() + " å¹´", shiftType));
        List<Map<String, Object>> mapYearList = baseMapper.performanceShiftYearList(time, userName, laboratory);
        annualAttendanceProcessing(mapYearList, shiftType);
        List<List<Object>> lists = dataRequiredForProcessingIntoExcel(mapYearList, shiftType);
        map.put("data", lists);
        return map;
    }
    @Override
    public Map<Object, Object> exportToMonthExcel(String time, String userName, String laboratory) {
        List<Enums> shiftType = enumService.selectEnumByCategory("班次类型");
        List<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftList(time, userName, laboratory);
        mapIPage.forEach(i -> {
            String[] shiftTimes = i.getShiftTime().split(";");
            int totalAttendance = 0;
            List<Map<String, Object>> map = new ArrayList<>();
            // åˆ†å‰²æ—¥æœŸ
            for (String shiftTime : shiftTimes) {
                Map<String, Object> hashMap = new HashMap<>();
                String[] shiftTimeAndShift = shiftTime.split(":");
                for (Enums enums : shiftType) {
                    if (!i.getMonthlyAttendance().containsKey(enums.getLabel())) {
                        i.getMonthlyAttendance().put(enums.getLabel(), 0);
                    }
                    if (enums.getValue().equals(shiftTimeAndShift[1])) {
                        Integer num = (Integer) i.getMonthlyAttendance().get(enums.getLabel());
                        i.getMonthlyAttendance().put(enums.getLabel(), num += 1);
                    }
                }
                if (shiftTimeAndShift[1].equals("1") || shiftTimeAndShift[1].equals("2") || shiftTimeAndShift[1].equals("0")) {
                    i.getMonthlyAttendance().put("totalAttendance", totalAttendance += 1);
                }
                hashMap.put("id", shiftTimeAndShift[2]);
                hashMap.put("shift", shiftTimeAndShift[1]);
                hashMap.put("time", shiftTimeAndShift[0]);
                map.add(hashMap);
            }
            i.setList(map);
            i.setShiftTime(null);
        });
        Map<Object, Object> map = new HashMap<>();
        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        // å°†å­—符串时间转换为 LocalDateTime ç±»åž‹æ—¶é—´
        LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
        map.put("header", getMonthHeader(localDateTime, shiftType));
        List<List<Object>> lists = dataRequiredForProcessingIntoExcelMonth(mapIPage, shiftType);
        map.put("data", lists);
        return map;
    }
@@ -330,15 +373,15 @@
     * æž„造双列表头
     * @return List<List<String>>
     */
    private static List<List<String>> getHeader(String month, List<Enums> enums){
    private static List<List<String>> getYearHeader(String year, List<Enums> enums){
        List<List<String>> line = new ArrayList<>();
        line.add(Arrays.asList("考勤汇总", "序号", "序号"));
        line.add(Arrays.asList("考勤汇总", "工号", "工号"));
        line.add(Arrays.asList("考勤汇总", "姓名", "姓名"));
        line.add(Arrays.asList("出勤详情", month, "出勤"));
        line.add(Arrays.asList("出勤详情", year, "出勤"));
        // å¹´ header
        for (Enums anEnum : enums) {
            line.add(Arrays.asList("考勤汇总", month, anEnum.getLabel()));
            line.add(Arrays.asList("考勤汇总", year, anEnum.getLabel()));
        }
        // æœˆheader
        for (int i = 1; i < 13; i++) {
@@ -349,4 +392,57 @@
        }
        return line;
    }
    private static List<List<String>> getMonthHeader(LocalDateTime localDateTimeYear, List<Enums> enums){
        String year = localDateTimeYear.getYear() + " å¹´äººå‘˜ç­æ¬¡";
        List<List<String>> line = new ArrayList<>();
        line.add(Arrays.asList(year, "序号", "序号", "序号"));
        line.add(Arrays.asList(year, "姓名", "姓名", "姓名"));
        line.add(Arrays.asList(year, "实验室", "实验室", "实验室"));
        line.add(Arrays.asList(year, localDateTimeYear.getYear() + "", localDateTimeYear.getYear() + "", "出勤"));
        line.add(Arrays.asList(year, localDateTimeYear.getYear() + "", localDateTimeYear.getYear() + "", enums.get(3).getLabel()));
        line.add(Arrays.asList(year, "å¹´", "å¹´", enums.get(4).getLabel()));
        line.add(Arrays.asList(year, localDateTimeYear.getMonthValue() + "", localDateTimeYear.getMonthValue() + "", enums.get(0).getLabel()));
        line.add(Arrays.asList(year, "月", "月", enums.get(1).getLabel()));
        line.add(Arrays.asList(year, "", "", enums.get(2).getLabel()));
        line.add(Arrays.asList(year, "周次", "星期", "出差"));
        LocalDate firstDayOfMonth = localDateTimeYear.toLocalDate().withDayOfMonth(1);
        LocalDate lastDayOfMonth = localDateTimeYear.toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
        List<LocalDateTime> timeList = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
        timeList.forEach(i -> {
            int dayOfYear = i.getDayOfMonth();
            Date from = Date.from(i.atZone(ZoneId.systemDefault()).toInstant());
            String weekDay = getWeekDay(i.getDayOfWeek().getValue());
            line.add(Arrays.asList(year, DateUtil.weekOfYear(DateUtil.offsetDay(from, 1)) + "", weekDay, dayOfYear + ""));
        });
        return line;
    }
    public List<List<Object>> dataRequiredForProcessingIntoExcelMonth(List<PerformanceShiftMapDto> list, List<Enums> enums) {
        List<List<Object>> data = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            List<Object> excelRowList = new ArrayList<>();
            excelRowList.add(i + 1);
            excelRowList.add(list.get(i).getName());
            excelRowList.add(list.get(i).getDepartment());
            excelRowList.add(list.get(i).getMonthlyAttendance().get("totalAttendance"));
            excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(3).getLabel()));
            excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(4).getLabel()));
            excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(0).getLabel()));
            excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(1).getLabel()));
            excelRowList.add(list.get(i).getMonthlyAttendance().get(enums.get(2).getLabel()));
            excelRowList.add(0); // å‡ºå·®
            for (Map<String, Object> o : list.get(i).getList()) {
                String enumLabel = "";
                for (Enums anEnum : enums) {
                    if (anEnum.getValue().equals(o.get("shift"))) {
                        enumLabel = anEnum.getLabel();
                    }
                }
                excelRowList.add(ObjectUtils.isEmpty(enumLabel) ? "无" : enumLabel);
            }
            data.add(excelRowList);
        }
        return data;
    }
}
performance-server/src/main/java/com/yuanchu/mom/utils/StyleMonthUtils.java
copy from performance-server/src/main/java/com/yuanchu/mom/utils/StyleUtils.java copy to performance-server/src/main/java/com/yuanchu/mom/utils/StyleMonthUtils.java
Îļþ´Ó performance-server/src/main/java/com/yuanchu/mom/utils/StyleUtils.java ¸´ÖÆ
@@ -4,7 +4,7 @@
import com.alibaba.excel.write.metadata.style.WriteFont;
import org.apache.poi.ss.usermodel.*;
public class StyleUtils {
public class StyleMonthUtils {
    /**
     * æ ‡é¢˜æ ·å¼
     * @return
@@ -13,26 +13,26 @@
        // å¤´çš„ç­–ç•¥
        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
        // èƒŒæ™¯é¢œè‰²
        headWriteCellStyle.setFillForegroundColor(IndexedColors.LIME.getIndex());
        headWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
        headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
        // å­—体
        WriteFont headWriteFont = new WriteFont();
        headWriteFont.setFontName("仿宋");//设置字体名字
        headWriteFont.setFontName("等线");//设置字体名字
        headWriteFont.setFontHeightInPoints((short)9);//设置字体大小
        headWriteFont.setBold(true);//字体加粗
        headWriteFont.setColor((short) 1);
        headWriteFont.setColor((short) 0);
        headWriteCellStyle.setWriteFont(headWriteFont); //在样式用应用设置的字体;
        // æ ·å¼
        headWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置底边框;
        headWriteCellStyle.setBottomBorderColor((short) 1);//设置底边框颜色;
        headWriteCellStyle.setBottomBorderColor((short) 0);//设置底边框颜色;
        headWriteCellStyle.setBorderLeft(BorderStyle.THIN);  //设置左边框;
        headWriteCellStyle.setLeftBorderColor((short) 1);//设置左边框颜色;
        headWriteCellStyle.setLeftBorderColor((short) 0);//设置左边框颜色;
        headWriteCellStyle.setBorderRight(BorderStyle.THIN);//设置右边框;
        headWriteCellStyle.setRightBorderColor((short) 1);//设置右边框颜色;
        headWriteCellStyle.setRightBorderColor((short) 0);//设置右边框颜色;
        headWriteCellStyle.setBorderTop(BorderStyle.THIN);//设置顶边框;
        headWriteCellStyle.setTopBorderColor((short) 1); //设置顶边框颜色;
        headWriteCellStyle.setTopBorderColor((short) 0); //设置顶边框颜色;
        headWriteCellStyle.setWrapped(false);  //设置自动换行;
@@ -53,24 +53,24 @@
        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
        // è¿™é‡Œéœ€è¦æŒ‡å®š FillPatternType ä¸ºFillPatternType.SOLID_FOREGROUND ä¸ç„¶æ— æ³•显示背景颜色.头默认了 FillPatternType所以可以不指定
        contentWriteCellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
//        contentWriteCellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
        contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
        // è®¾ç½®å­—体
        WriteFont contentWriteFont = new WriteFont();
        contentWriteFont.setFontHeightInPoints((short) 9);//设置字体大小
        contentWriteFont.setFontName("仿宋"); //设置字体名字
        contentWriteFont.setFontHeightInPoints((short) 10);//设置字体大小
        contentWriteFont.setFontName("等线"); //设置字体名字
        contentWriteCellStyle.setWriteFont(contentWriteFont);//在样式用应用设置的字体;
        //设置样式;
//        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置底边框;
//        contentWriteCellStyle.setBottomBorderColor((short) 1);//设置底边框颜色;
        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置底边框;
        contentWriteCellStyle.setBottomBorderColor((short) 0);//设置底边框颜色;
        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);  //设置左边框;
        contentWriteCellStyle.setLeftBorderColor((short) 1);//设置左边框颜色;
        contentWriteCellStyle.setLeftBorderColor((short) 0);//设置左边框颜色;
        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);//设置右边框;
        contentWriteCellStyle.setRightBorderColor((short) 1);//设置右边框颜色;
        contentWriteCellStyle.setRightBorderColor((short) 0);//设置右边框颜色;
        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);//设置顶边框;
        contentWriteCellStyle.setTopBorderColor((short) 1); ///设置顶边框颜色;
        contentWriteCellStyle.setTopBorderColor((short) 0); ///设置顶边框颜色;
        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// æ°´å¹³å±…中
        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// åž‚直居中
performance-server/src/main/java/com/yuanchu/mom/utils/StyleYearUtils.java
ÎļþÃû´Ó performance-server/src/main/java/com/yuanchu/mom/utils/StyleUtils.java ÐÞ¸Ä
@@ -4,7 +4,7 @@
import com.alibaba.excel.write.metadata.style.WriteFont;
import org.apache.poi.ss.usermodel.*;
public class StyleUtils {
public class StyleYearUtils {
    /**
     * æ ‡é¢˜æ ·å¼
     * @return
@@ -13,7 +13,7 @@
        // å¤´çš„ç­–ç•¥
        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
        // èƒŒæ™¯é¢œè‰²
        headWriteCellStyle.setFillForegroundColor(IndexedColors.LIME.getIndex());
        headWriteCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());
        headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
        // å­—体
@@ -53,7 +53,7 @@
        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
        // è¿™é‡Œéœ€è¦æŒ‡å®š FillPatternType ä¸ºFillPatternType.SOLID_FOREGROUND ä¸ç„¶æ— æ³•显示背景颜色.头默认了 FillPatternType所以可以不指定
        contentWriteCellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
        contentWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
        // è®¾ç½®å­—体
performance-server/src/main/resources/mapper/PerformanceShiftMapper.xml
@@ -6,6 +6,7 @@
        <result column="name" property="name"/>
        <result column="shift_time" property="shiftTime"/>
        <result column="user_id" property="userId" />
        <result column="department" property="department" />
    </resultMap>
    <select id="performanceShiftPage" resultMap="performanceShiftPageMap">
@@ -85,4 +86,23 @@
        GROUP BY u.id
        order by s.work_time
    </select>
    <select id="performanceShiftList" resultMap="performanceShiftPageMap">
        SELECT
        if(u.department is not null and u.department != '', CONCAT(u.name, '(', u.department, ')'), u.name) name,
        GROUP_CONCAT(s.work_time, ':', s.shift, ':', s.id order by s.work_time SEPARATOR ';') AS shift_time, u.id user_id, u.department
        FROM performance_shift s
        LEFT JOIN user u on u.id = s.user_id
        <where>
            <if test="time != null and time != ''">
                and DATE_FORMAT(s.work_time, '%Y-%m') = DATE_FORMAT(#{time}, '%Y-%m' )
            </if>
            <if test="userName != null and userName != ''">
                and u.name like concat('%', #{userName}, '%')
            </if>
            <if test="laboratory != null and laboratory != ''">
            </if>
        </where>
        GROUP BY u.id
    </select>
</mapper>
system-run/src/test/java/com/yuanchu/mom/SystemRunApplicationTest.java
@@ -1,14 +1,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.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 {
    @Autowired
    private PerformanceShiftService performanceShiftService;
    private static String fileName = "D:\\" + System.currentTimeMillis() + ".xlsx";
    @Test
    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);
    }
}