package com.gz;

import cn.hutool.core.date.DateUtil;
import com.gz.mapper.borrow.ArchiveBorrowMapper;
import com.gz.mapper.system.ArchivesTreeMapper;
import com.gz.mapper.welcome.StatisticsMapper;
import com.gz.rvo.borrow.ArchiveBorrowHistoryRVO;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author LiuchangLan
 * @date 2021/3/3 11:49
 */
@SpringBootTest
public class BorrowCountTest {

    @Resource
    private ArchivesTreeMapper archivesTreeMapper;

    @Resource
    private ArchiveBorrowMapper archiveBorrowMapper;

    @Resource
    private StatisticsMapper statisticsMapper;


    @Test
    public void test(){
        // 所有历史记录
        List<ArchiveBorrowHistoryRVO> archiveBorrowHistorys = archiveBorrowMapper.selectArchiveBorrowHistory(null);
        // 根据门类分组后
        Map<String, List<ArchiveBorrowHistoryRVO>> historyByMl = archiveBorrowHistorys.stream().sorted(Comparator.comparing(archiveBorrowHistoryRVO -> DateUtil.parse(archiveBorrowHistoryRVO.getCreateTime()))).collect(Collectors.groupingBy(ArchiveBorrowHistoryRVO::getMl));
        List<String> x = archiveBorrowHistorys.stream().sorted(Comparator.comparing(archiveBorrowHistoryRVO -> DateUtil.parse(archiveBorrowHistoryRVO.getCreateTime()))).map(ArchiveBorrowHistoryRVO::getCreateTime).collect(Collectors.toList());


    }

}
