

import com.engine.attendance.attendanceanalysis.cmd.GetClockInTimeItemCmd;
import com.engine.attendance.enums.AttendanceItemTypeEnum;
import com.engine.common.util.DateUtil;
import com.engine.common.util.Utils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import weaver.general.Util;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;


public class Test {
    public static void main(String[] args) {
        System.out.println(UUID.randomUUID().toString());
//        List<Integer> list = Lists.newArrayList();
//        aa(list);
//        System.out.println(list);
//        Map<String,Object> params = Maps.newHashMap();
//        List<Map<String,Object>> attendanceItems  = new ArrayList<>();
//        Map<String,Object> map = new HashMap<>();
//        map.put("xmlx","1");
//        map.put("zysd","1");
//        map.put("zxhsl","60");
//        map.put("zdhsl","180");
//        map.put("signdate","2023-10-31");
//        map.put("signtime","08:55:16");
//        Map<String,Object> map2 = new HashMap<>();
//        map2.put("xmlx","2");
//        map2.put("zysd","2");
//        map2.put("signdate","2023-11-31");
//        map2.put("signtime","12:55:16");
//        Map<String,Object> map3 = new HashMap<>();
//        map3.put("xmlx","3");
//        map3.put("zysd","1");
//        map3.put("zxhsl","0");
//        map3.put("signdate","2023-10-31");
//        map3.put("signtime","13:55:16");
//        attendanceItems.add(map);
//        attendanceItems.add(map2);
//        attendanceItems.add(map3);
////        params.put("attendanceItems",attendanceItems);
////        params.put("workfor","1");
////        params.put("time","50");
//
////        List<Map<String,Object>> dataList = attendanceItems.stream().filter(e->"1".equals(e.get("zysd"))).collect(Collectors.toList());
////        System.out.println(dataList);
//       // Map<String,Object> resultMap = attendanceItems.stream().min(Comparator.comparing(e->DateUtil.getTime(e.get("signdate")+" "+e.get("signtime")).toInstant(ZoneOffset.of("+8")).toEpochMilli())).get();
//
//        List<Map<String,Object>> resultList = attendanceItems.stream().sorted(Comparator.comparing(e->DateUtil.getTime(e.get("signdate")+" "+e.get("signtime")).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());

//        attendanceItems.remove(resultMap);
     //   System.out.println(resultList);
//        new AbsenteeismCmd(params).execute(null);

//        for (int i=0;i<5;i++){
//            if (i == 3){
//                break;
//            }
//            System.out.println(i);
//        }
       // System.out.println("aaaa");

        List<Map<String,Object>> managerList = Lists.newArrayList();

        managerList.add(new HashMap(){{
            put("id","1");

        }});
        managerList.add(new HashMap(){{
            put("id","2");

        }});
        managerList.add(new HashMap(){{
            put("id","1");

        }});
        Set<String> managerIds = managerList.stream().map(e->Util.null2String(e.get("id"))).collect(Collectors.toSet());

//        System.out.println(managerIds);

        List<String> list = Lists.newArrayList();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");

        for (int i=0;i<list.size();i++){
            System.out.println(list.get(i));
            if ("2".equals(list.get(i))){
                list.remove(list.get(i));
               i--;
            }
        }

        System.out.println(list);
        //System.out.println(AttendanceItemTypeEnum.MISSE_CARD.equals(AttendanceItemTypeEnum.MISSE_CARD));

        //System.out.println(Util.getIntValue(""));
//        List<Map<String,Object>> beforeleaveDate = Lists.newArrayList();
//        for (int i=beforeleaveDate.size()-1;i>=0;i--){
//            System.out.println(123123);
//        }
//        System.out.println("".split("-")[0]);
//        for (int i=0;i<5;i++){
//            int j=i+1;
//            if (j > 5-1){
//                j = 5-1;
//            }
//            System.out.println(j);
//        }
//        Map<String,Object> jsdkNearestClcokInTime = Maps.newHashMap();
//        jsdkNearestClcokInTime.put("after","222");
//        //jsdkNearestClcokInTime.put("before","222");
//        jsdkNearestClcokInTime.put("equal","222");
//        if (jsdkNearestClcokInTime.get("equal") != null){
//            System.out.println(111);
//        }else if (jsdkNearestClcokInTime.get("after") != null){
//            System.out.println(222);
//        }else if (jsdkNearestClcokInTime.get("before") != null){
//            System.out.println(333);
//        }
//        List<Map> lists = Lists.newArrayList();
////        List<Map> lists2 = Lists.newArrayList();
////        List<Map> lists3 = Lists.newArrayList();
//        lists.add(new HashMap(){{
//            put("key","1");
//        }});
//        lists.add(new HashMap(){{
//            put("key","2");
//        }});
//        lists.add(new HashMap(){{
//            put("key","3");
//        }});
//
//        Map map1 = lists.get(0);
//        Map map2 = lists.get(1);
//
//        List<Map> list2 = lists.stream().filter(e -> e.get("key").equals("1")).collect(Collectors.toList());
//
//        Map map3 = list2.get(0);
//        map3.put("value","222");
//        System.out.println(DateUtil.getBetWeenMinutes("2023-11-16 08:00","2023-11-16 09:10"));
       // BigDecimal durationBig = new BigDecimal(1.5);

//        List<Map<String,String>> list = Lists.newArrayList();
//
//        List<Map<String,String>> list2 = Lists.newArrayList();
//        list2.add(new HashMap(){{
//            put("one","aa");
//        }});
//        list.addAll(list2);
//        list.get(0).put("two","bb");
////        System.out.println(list2);
////        System.out.println(list);
//
//        Map<String,Object> map1 = Maps.newHashMap();
//        map1.put("aa","bb");
//        Map<String,Object> map2 = Maps.newHashMap();
//        map2.putAll(map1);
//        map2.put("bb","ss");;
//        map1.put("cc","cc");
//        System.out.println(map1);
//        System.out.println(map2);



//        list.add(new HashMap(){{
//            put("aa","bb");
//        }});
//        list.add(new HashMap(){{
//            put("bb","cc");
//        }});
//        Map<String,String> map1 = list.get(0);
//
//        map1.remove("aa");
//        map1.put("dd","aa");

//      //  System.out.println(list);
//        System.out.println(DateUtil.getBetWeenMinutes("2023-11-20 10:39","2023-11-20 11:39"));
//        System.out.println(DateUtil.getBetWeenMinutes("2023-11-20 12:39","2023-11-20 11:39"));
    //    System.out.println("11,12,33".split(",").length);
       // System.out.println(Utils.getItemdurationDown(5.0,AccountingUnitEnum.MINUTES.getKey(),36,AccountingUnitEnum.MINUTES));
       //System.out.println( durationBig.divide(hslBig,BigDecimal.ROUND_DOWN).multiply(hslBig).add(hslBig,new MathContext(BigDecimal.ROUND_HALF_DOWN)).doubleValue());
//        System.out.println(Utils.getItemduration(1,"1",DateUtil.getBetWeenMinutes("2023-11-16 08:00","2023-11-16 09:10"),AccountingUnitEnum.MINUTES));

//        lists2.add(lists.get(1));
//        lists3.add(lists.get(1));
//        if (lists2.get(0) == lists3.get(0)){
//            System.out.println(1111);
//        }
      // System.out.println("aa|aa|ss".split("\\|")[2]);
//        AccountingUnitEnum accountingUnitEnum = AccountingUnitEnum.HOUR;
//        AccountingUnitEnum accountingUnitEnum2 = AccountingUnitEnum.HOUR;
//        List<Map<String,Object>> lists = Lists.newArrayList();
//        lists.add(new HashMap(){{
//            put("item",102);
//            put("betweenMinutes",15);
//            put("itemduration",15.0);
//            put("pointTime","2023-11-14 09:00");
//        }});
//        lists.add(new HashMap(){{
//            put("item",7);
//            put("itemduration",1);
//            put("pointTime","2023-11-14 13:00");
//        }});
//        lists.add(new HashMap(){{
//            put("item",11);
//            put("betweenMinutes",13);
//            put("itemduration",13.0);
//            put("pointTime","2023-11-14 18:30");
//        }});
//        lists = lists.stream().filter(e -> e.get("betweenMinutes") != null).collect(Collectors.toList());
//        lists = lists.stream().sorted(Comparator.comparing(e->Integer.valueOf(e.get("betweenMinutes").toString()))).collect(Collectors.toList());
//
//        System.out.println(lists);
//
//        Map<String,Object> param = Maps.newHashMap();
//        param.put("qjsc","0.5");
//        System.out.println(Double.valueOf(Double.valueOf(param.get("qjsc").toString())*60).intValue());

//        System.out.println(DateUtil.getBetWeenDays("2023-11-15","2023-11-15"));
        //System.out.println(lists.hashCode());
//        List lists2 = lists.stream().sorted(Comparator.comparing(e->Integer.valueOf(e.get("betweenMinutes").toString()))).collect(Collectors.toList());
//        lists.addAll(lists2);
//        lists.addAll(lists2);
//        System.out.println(lists2);
//
//        System.out.println(Double.valueOf("1.00").intValue()*60);
//        String analysisDate = "2023-11-22";
//        List<String> lists = Lists.newArrayList();
//        lists.add("aa");
//        lists.add("aa");
//        lists.add("bb");
//        List<String> lists2 = lists.stream().filter(e->e.equals("aa")).collect(Collectors.toList());
//        System.out.println(lists.size());
//        System.out.println(lists2.size());
//        BigDecimal s = new BigDecimal(110.0);
//        List<Map<String,Object>> list1
//        System.out.println(8.0*0.3);

        //System.out.println(Utils.getItemdurationDown(15,AccountingUnitEnum.MINUTES.getKey(),59,AccountingUnitEnum.MINUTES));
//        Calendar calendar = Calendar.getInstance();
//        calendar.set(Integer.valueOf(analysisDate.split("-")[0]), Integer.valueOf(analysisDate.split("-")[1]) - 1, 1);
//        int day = TimeUtil.getDayOfWeek(analysisDate);
//        System.out.println(DateUtil.AfterDay(analysisDate,0));
       // System.out.println(calendar.getActualMaximum(Calendar.DAY_OF_WEEK));

//        List<Map<String, Object>> lists = Lists.newArrayList();
//        lists.add(new HashMap(){{
//            put("sjjbsc","5");
//        }});
//        lists.add(new HashMap(){{
//            put("sjjbsc","5");
//        }});
//
//
//        System.out.println(lists.stream().mapToInt(e->Integer.valueOf(e.get("sjjbsc").toString())).sum());
      //  System.out.println(DateUtil.getTime("2023-11-15 10:00:00").compareTo(DateUtil.getTime("2023-11-15 09:00:00")));
        //long numDays = DateUtil.getBetWeenMinutes("2023-11-08 17:40","2023-11-08 16:30");
//        BigDecimal duration = new BigDecimal(5);
//        BigDecimal hsl = new BigDecimal(0.6);
//        System.out.println(duration.divide(hsl,BigDecimal.ROUND_DOWN).multiply(hsl).add(hsl,new MathContext(BigDecimal.ROUND_HALF_DOWN)).doubleValue());
      //  System.out.println(DateUtil.AfterMinutes("2023-11-08 15:40:05",numDays/2));
      // System.out.println(Integer.valueOf(Util.null2String(null)));

//        List<Map<String, Object>> clockInTimeList = Lists.newArrayList();
//        clockInTimeList.add(new HashMap(){{
//            put("signdate","2023-11-12");
//            put("signtime","08:47:43");
//        }});
//        clockInTimeList.add(new HashMap(){{
//            put("signdate","2023-11-12");
//            put("signtime","09:47:43");
//        }});
//        clockInTimeList.add(new HashMap(){{
//            put("signdate","2023-11-12");
//            put("signtime","10:47:43");
//        }});
//
//        clockInTimeList.add(new HashMap(){{
//            put("signdate","2023-11-13");
//            put("signtime","11:05:43");
//        }});
//        System.out.println(Utils.getNearestClcokInTimeCmd("2023-11-12 08:46:43",clockInTimeList));
//
       // testGetClockInTimeItemCmd();
        //System.out.println(DateUtil.beforeDay("2023-10-31",1));
//        List<Map<String,Object>> personGroupOrganizationList = Lists.newArrayList();
//        personGroupOrganizationList.add(new HashMap(){{put("dx","4-夜班人员");}});
//        personGroupOrganizationList.add(new HashMap(){{put("dx","8-测试条件录入");}});
//        Set<String> personGroupIds = personGroupOrganizationList.stream().map(e -> Util.null2String(e.get("dx")).split("-")[0]).collect(Collectors.toSet());
//        System.out.println(String.join(",",personGroupIds));
//        List<String> list = Lists.newArrayList();
//        list.add("1");
//        list.add("2");
//        list.add("5");
//        System.out.println(list);
//        list.add(1,"10");
     //  Map<String,Object> map = new HashMap(){{
           //put("11","22");
//           put("33","44");
//           put("44","66");
//       }};
//       System.out.println(map);
    }

    public static int getDaysBetween(String date1, String date2) {
        LocalDate startDate = LocalDate.parse(date1);
        LocalDate endDate = LocalDate.parse(date2);

        long daysBetween = ChronoUnit.DAYS.between(startDate, endDate);
        return Math.toIntExact(daysBetween);
    }


    /**
     * 测试获取当天打卡测试类
     */
    public static void testGetClockInTimeItemCmd(){
        String beforeOneDayDate = DateUtil.getCurrentDateMinusDay(2);
        List<Map<String,Object>> dataList = Lists.newArrayList();
        dataList.add(new HashMap(){{
            put("signtime","23:50:00");
            put("id","48");
            put("userid","53");
            put("signdate","2023-11-11");
        }});

        dataList.add(new HashMap(){{
            put("signtime","01:10:00");
            put("id","48");
            put("userid","53");
            put("signdate","2023-11-12");
        }});
        dataList.add(new HashMap(){{
            put("signtime","01:20:00");
            put("id","48");
            put("userid","53");
            put("signdate","2023-11-12");
        }});
        dataList.add(new HashMap(){{
            put("signtime","09:15:00");
            put("id","48");
            put("userid","53");
            put("signdate","2023-11-12");
        }});
        dataList.add(new HashMap(){{
            put("signtime","12:17:00");
            put("id","49");
            put("userid","53");
            put("signdate","2023-11-12");
        }});
        dataList.add(new HashMap(){{
            put("signtime","18:17:00");
            put("id","49");
            put("userid","53");
            put("signdate","2023-11-12");
        }});
        dataList.add(new HashMap(){{
            put("signtime","01:17:00");
            put("id","49");
            put("userid","53");
            put("signdate","2023-11-13");
        }});
        dataList.add(new HashMap(){{
            put("signtime","03:17:00");
            put("id","49");
            put("userid","53");
            put("signdate","2023-11-13");
        }});

        Map<String, List<Map<String,Object>>> collect = dataList.stream().collect(Collectors.groupingBy(e -> Util.null2String(e.get("signdate"))));
        List<Map<String,Object>> schedulingList = Lists.newArrayList();
        schedulingList.add(new HashMap(){{
            put("edsc","9.50");
            put("bdlx","0");
            put("jsdk","0");
            put("tqdkfzs","120");
            put("sfkt","1");
            put("dtjssj","09:00");
            put("zddxfz","30");
            put("bcxx","25");
            put("dxhs","5");
            put("bcsdxx","09:00-13:00|13:00-18:30");
            put("sfdx","0");
            put("dtkssj","01:00");
            put("thdkfzs","120");
            put("ksdk","1");
            put("rqlx","11");
        }});
        schedulingList.add(new HashMap(){{
            put("edsc","9.50");
            put("bdlx","0");
            put("jsdk","1");
            put("tqdkfzs","60");
            put("sfkt","1");
            put("dtjssj","13:00");
            put("zddxfz","30");
            put("bcxx","25");
            put("dxhs","5");
            put("bcsdxx","09:00-13:00|13:00-18:30");
            put("sfdx","0");
            put("dtkssj","09:00");
            put("thdkfzs","60");
            put("ksdk","1");
            put("rqlx","11");
        }});
        schedulingList.add(new HashMap(){{
            put("edsc","9.50");
            put("bdlx","0");
            put("jsdk","1");
            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","0");
            put("dtkssj","03:00");
            put("thdkfzs","60");
            put("ksdk","0");
            put("rqlx","11");
        }});
        schedulingList.add(new HashMap(){{
            put("edsc","9.50");
            put("bdlx","0");
            put("jsdk","0");
            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","0");
            put("dtkssj","18:00");
            put("thdkfzs","60");
            put("ksdk","0");
            put("rqlx","11");
        }});
        schedulingList.add(new HashMap(){{
            put("edsc","9.50");
            put("bdlx","0");
            put("jsdk","1");
            put("tqdkfzs","60");
            put("sfkt","1");
            put("dtjssj","01:00");
            put("zddxfz","30");
            put("bcxx","25");
            put("dxhs","5");
            put("bcsdxx","09:00-13:00|13:00-18:30");
            put("sfdx","0");
            put("dtkssj","21:00");
            put("thdkfzs","60");
            put("ksdk","0");
            put("rqlx","11");
        }});

        Map<String,List<Map<String,Object>>> schedulingResultsMap = Maps.newHashMap();
        schedulingResultsMap.put("2023-11-12",schedulingList);
        schedulingResultsMap.put("2023-11-13",schedulingList);
        schedulingResultsMap.put("2023-11-11",schedulingList);


        Map<String,Object> params = Maps.newHashMap();
        params.put("date",beforeOneDayDate);
        params.put("clockInTimeCollect",collect);
        params.put("schedulingResultCollect",schedulingResultsMap);


    }

    public  static void aa(List<Integer> list){
        list.add(1);
        list.add(5);
        list.add(4);
        list = list.stream().filter(e -> e <=4).collect(Collectors.toList());
    }
}
