package com.api.customization.qc3189074.util;

import com.wbi.util.Util;
import weaver.common.DateUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;

public class ScheduleRejectAction implements Action {
    @Override
    public String execute(RequestInfo requestInfo) {
        CustomScheduleUtil customScheduleUtil = new CustomScheduleUtil();
        String requestid = requestInfo.getRequestid();
        //获取主表数据
        Map<String, String> mainDatas = new HashMap<>();
        Property[] properties = requestInfo.getMainTableInfo().getProperty();
        for (Property propertie : properties) {
            mainDatas.put(propertie.getName(), propertie.getValue());
        }
        //获取主表排班月份
        String kqMonth = Util.null2String(mainDatas.get("pbyf"));
        String groupid = Util.null2String(mainDatas.get("kqz"));//排班考勤组

        String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01");
        String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01");
        //获取主表被排班人员
        String[] resourceIds = Util.null2String(mainDatas.get("pbmd")).split(",");

        //把状态改为待提交
        customScheduleUtil.setStatus(mainDatas.get("pbmd"),kqMonth,"1",Integer.parseInt(requestid),groupid);
        return SUCCESS;
    }
}
