package TestAttendanceAllowance;

import com.engine.jucailinkq.attendance.attendanceanalysis.dto.clockpoint.ClockPointDTO;
import com.engine.jucailinkq.attendance.attendanceanalysis.job.AttendanceAnalysisJob;
import com.engine.jucailinkq.attendance.attendanceanalysis.web.AttendanceanalysisAction;
import com.engine.jucailinkq.attendance.component.calendarscheduling.service.WorkRulesService;
import com.engine.jucailinkq.attendance.component.calendarscheduling.service.impl.WorkRulesServiceImpl;
import com.engine.common.util.ServiceUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import weaver.hrm.User;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class

Test extends beforlog{
    private WorkRulesService getWorkRulesService(User user) {
        return ServiceUtil.getService(WorkRulesServiceImpl.class,user);
    }

    @org.junit.Test
    public void testAnalysis() throws Exception{
        Map<String,Object> paramMap = Maps.newHashMap();
        paramMap.put("startDate","2024-07-4");
        paramMap.put("endDate","2024-07-03");
        paramMap.put("userIds","31");

        beforlog be = new beforlog();
        AttendanceanalysisAction action = new AttendanceanalysisAction();
        action.getSchedulingData(null,null);

    }

    @org.junit.Test
    public void testAnalysisJob() throws Exception{
        AttendanceAnalysisJob job = new AttendanceAnalysisJob();
        job.execute();
    }

    @org.junit.Test
    public void testRealse() throws Exception{
        Map<String, Object> params = Maps.newHashMap();
        params.put("resourceIds","22");
        params.put("bcxx","11");
        params.put("date","2024-06-01,2024-06-02,2024-06-09,2024-06-16,2024-06-23,2024-06-30,2024-06-03,2024-06-10,2024-06-17,2024-06-24,2024-07-01,2024-06-04,2024-06-11,2024-06-18,2024-06-25,2024-07-02,2024-06-05,2024-06-12,2024-06-19,2024-06-26,2024-06-06,2024-06-13,2024-06-20,2024-06-27,2024-07-03,2024-07-04,2024-06-07,2024-06-14,2024-06-21,2024-06-28,2024-07-05,2024-06-08,2024-06-15,2024-06-22,2024-06-29,2024-07-06");
        User user = new User(1);
        getWorkRulesService(user).saveCalendarWork(params);

    }

    @org.junit.Test
    public void testRealse2() throws Exception{
        Map<String, Object> params = Maps.newHashMap();
        params.put("resourceIds","101");
        params.put("bcxx","101");
        params.put("date","2024-06-17");
        User user = new User(1);
        getWorkRulesService(user).saveCalendarWork(params);

    }
    @org.junit.Test
    public void testRealse3() throws Exception{
        List<Map<String,Object>> sonItemList = Lists.newArrayList();
        Map<String,List<Map<String,Object>>> sonGroupMap = sonItemList.stream().collect(Collectors.groupingBy(e->e.get("sjxm").toString()));

    }
    @org.junit.Test
    public void testRealse4() throws Exception{
        List<Map<String,Object>> sonItemList = Lists.newArrayList();
        Map<String,Object> map1 = Maps.newHashMap();
        map1.put("key","1");
        Map<String,Object> map2 = Maps.newHashMap();
        map2.put("key","2");
        Map<String,Object> map3 = Maps.newHashMap();
        map3.put("key","3");
        sonItemList.add(map1);
        sonItemList.add(map2);
        sonItemList.add(map3);
        List<Map<String,Object>> resultList = Lists.newArrayList();
        for (int i=0;i<2;i++){
            for (Map<String,Object> scheduleMap:sonItemList){
                resultList.add(scheduleMap);
            }
        }
        System.out.println(resultList);
    }

}
