import com.engine.attendance.attendanceanalysis.cmd.getclockInpoint.GetClockInPointCmd;
import com.engine.attendance.enums.CheckBoxEnum;
import com.engine.attendance.enums.ClassSegmentTypeEnum;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

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

public class TestGetClockInPoint {

    public static void main(String[] args) {
        List<Map<String,Object>> schedulingList = Lists.newArrayList();
        schedulingList.add(new HashMap(){{
            put("edsc","8");
            put("bdlx","0");
            put("fgsjd","15:10");
            put("jsdk","0");
            put("tqdkfzs","120");
            put("sfxx","0");
            put("edxss","3.00");
            put("sfkt","0");
            put("dtjssj","12:00");
            put("dtsfdx","0");
            put("dtzddxfz","30");
            put("btgz","0");
            put("zddxfz","30");
            put("bcxx","1");
            put("dxhs","5");
            put("bcsdxx","09:00-12:00|13:00-18:00");
            put("sfdx","0");
            put("dtkssj","09:00");
            put("dtdxhs","5");
            put("zgzsc","8.00");
            put("thdkfzs","");
            put("ksdk","1");
            put("rqlx","0");
        }});
        schedulingList.add(new HashMap(){{
            put("edsc","8");
            put("bdlx","1");
            put("fgsjd","15:10");
            put("jsdk","1");
            put("tqdkfzs","");
            put("sfxx","0");
            put("edxss","3.00");
            put("sfkt","0");
            put("dtjssj","18:00");
            put("dtsfdx","0");
            put("dtzddxfz","30");
            put("btgz","0");
            put("zddxfz","30");
            put("bcxx","1");
            put("dxhs","5");
            put("bcsdxx","09:00-12:00|13:00-18:00");
            put("sfdx","0");
            put("dtkssj","13:00");
            put("dtdxhs","5");
            put("zgzsc","8.00");
            put("thdkfzs","240");
            put("ksdk","1");
            put("rqlx","0");
        }});
        schedulingList.add(new HashMap(){{
            put("edsc","9.50");
            put("bdlx","2");
            put("jsdk","1");
            put("tqdkfzs","60");
            put("sfkt","1");
            put("dtjssj","21:00");
            put("zddxfz","30");
            put("bcxx","25");
            put("dxhs","5");
            put("bcsdxx","09:00-13:00|13:00-18:30");
            put("sfdx","1");
            put("dtkssj","19:00");
            put("thdkfzs","120");
            put("ksdk","1");
            put("rqlx","11");
        }});


        List<Map<String,Object>> dataList = Lists.newArrayList();
        dataList.add(new HashMap(){{
            put("signtime","09:42:00");
            put("id","48");
            put("userid","81");
            put("signdate","2024-04-10");
        }});
        dataList.add(new HashMap(){{
            put("signtime","20:46:00");
            put("id","48");
            put("userid","81");
            put("signdate","2024-04-10");
        }});
//        dataList.add(new HashMap(){{
//            put("signtime","18:29:00");
//            put("id","48");
//            put("userid","53");
//            put("signdate","2023-11-12");
//        }});
//        dataList.add(new HashMap(){{
//            put("signtime","19:08:00");
//            put("id","48");
//            put("userid","53");
//            put("signdate","2023-11-12");
//        }});


        Map<String,Object> param = Maps.newHashMap();
        List<Map<String,Object>> askForLeaveAndEvctionSchedule = Lists.newArrayList();
//        askForLeaveAndEvctionSchedule.add(new HashMap(){{
//            put("edsc","9.50");
//            put("bdlx",ClassSegmentTypeEnum.ASK_FOR_LEAVE.getKey());
//            put("jsdk","0");
//            put("tqdkfzs","60");
//            put("sfkt","1");
//            put("dtjssj","18:00");
//            put("zddxfz","30");
//            put("bcxx","25");
//            put("dxhs","5");
//            put("bcsdxx","09:00-13:00|13:00-18:30");
//            put("sfdx","1");
//            put("dtkssj","11:00");
//            put("thdkfzs","60");
//            put("ksdk","0");
//            put("rqlx","11");
//        }});
        param.put("analysisDate","2024-04-10");
        param.put("scheduleResult",schedulingList);
        param.put("clockInTimeList",dataList);
        param.put("askForLeaveAndEvctionSchedule",askForLeaveAndEvctionSchedule);


        List<Map<String, Object>> needClockInList = schedulingList.stream().filter(e -> {
            if (!ClassSegmentTypeEnum.REST_AND_DINE.getKey().equals(e.get("bdlx")) && !ClassSegmentTypeEnum.REST_PERIOD.getKey().equals(e.get("bdlx")) &&
                    !ClassSegmentTypeEnum.DINING_PERIOD.getKey().equals(e.get("bdlx")) && (CheckBoxEnum.CHECKED.getKey().equals(e.get("ksdk")) || CheckBoxEnum.CHECKED.getKey().equals(e.get("jsdk")))){
                return true;
            }else {
                return false;
            }
        }).collect(Collectors.toList());
        Map<String, Object> firstKsdkSchedule = null;
        for (int i=0;i<needClockInList.size();i++){
            if (CheckBoxEnum.CHECKED.getKey().equals(needClockInList.get(i).get("ksdk"))){
                firstKsdkSchedule = needClockInList.get(i);
                System.out.println(firstKsdkSchedule);
                break;
            }
        }
        System.out.println(firstKsdkSchedule);
       // List<Map<String, Map<String,Object>>> collect = getClockInPoint("2023-11-12",schedulingList,dataList);
        List<Map<String, Map<String,Object>>> collect = (List<Map<String, Map<String, Object>>>)new GetClockInPointCmd(param).execute(null).get("clcokInTimeData");

//        Map<String,Object> clock = getNeedRecordClockInTime(collect);
//        System.out.println(clock);

    }

}
