package sy;

import ComprehensiveWorkingHourServiceImpl.beforlog;
import com.engine.common.util.ServiceUtil;
import com.engine.jucailinkq.attendance.component.AttendanceCycle.service.AttendanceCycleService;
import com.engine.jucailinkq.attendance.component.AttendanceCycle.service.impl.AttendanceCycleServiceImpl;
import com.engine.jucailinkq.attendance.workflow.service.AllowanceService;
import com.engine.jucailinkq.attendance.workflow.service.impl.AllowanceServiceImpl;
import com.engine.jucailinkq.common.util.DateUtil;
import com.google.common.collect.Maps;
import org.junit.Test;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;

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

/**
 * @Author: sy
 * @Description:
 * @Date: 2024/5/13
 **/
public class testAttendanceCycle extends beforlog {

    private AttendanceCycleService getAttendanceCycleService = ServiceUtil.getService(AttendanceCycleServiceImpl.class);
    @Test
    public void test() throws Exception {
        User user = new User();
        user.setUid(1);
        user.setLanguage(7);

        List<Map<String, String>> detailTableData = new ArrayList<>();
        Map<String, String> detailDataItem = new HashMap<>();
        detailDataItem.put("rq", "2024-07-04");
        detailTableData.add(detailDataItem);

        Map<String, Object> params = Maps.newHashMap();
        params.put("userId", "81");
        params.put("submitDate", DateUtil.getCurrentDate());
        params.put("submitStr","rq");
        params.put("submitDataList",detailTableData);

        Map<String,Object> dataMap = getAttendanceCycleService.getKqCycleCheckoutInfoCmd(params);
        List<Map<String,Object>> checkoutList = (List<Map<String,Object>>)dataMap.get("checkoutList");
        List<String> nocycleList = (List<String>)dataMap.get("nocycleList");
        boolean status = (boolean)dataMap.get("status");
        if (!status){
            System.out.println("该人员没有考勤周期");

        }
        if (checkoutList.size() > 0 || nocycleList.size() > 0){
            String message = "";
            if (nocycleList.size() > 0){
                message = message +String.join(",",nocycleList)+"未找对对应的考勤周期；";
            }
            if (checkoutList.size() > 0){
                List<String> list = checkoutList.stream().map(e->e.get("rq").toString()).collect(Collectors.toList());
                message = message +String.join(",",list)+"对应的考勤周期的考勤周期已结账";
            }
            System.out.println(message);
        }


    }

}
