package com.engine.kq.cmd.holidaySet;

import com.api.browser.bean.SearchConditionItem;
import com.api.browser.util.ConditionFactory;
import com.api.browser.util.ConditionType;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.hrm.User;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.systemright.CheckSubCompanyRight;

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

/**
 * 节假日设置--Excel导入时的表单
 */
public class GetImportFormCmd extends AbstractCommonCommand<Map<String, Object>> {

    public GetImportFormCmd(Map<String, Object> params, User user) {
        this.user = user;
        this.params = params;
    }

    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
        Map<String, Object> resultMap = new HashMap<String, Object>();

        List<Map<String, Object>> groupList = new ArrayList<Map<String, Object>>();
        Map<String, Object> groupItem = new HashMap<String, Object>();
        List<Object> itemList = new ArrayList<Object>();
        SearchConditionItem searchConditionItem = null;

        String filePath = "/hrm/import/templet/KQHolidaySet.xls";
        if(user.getLanguage()==9){
            filePath = "/hrm/import/templet/traditional/KQHolidaySet.xls";
        }else if(user.getLanguage()==8){
            filePath = "/hrm/import/templet/englisgh/KQHolidaySet.xls";
        }


        groupItem.put("title", SystemEnv.getHtmlLabelName(384128, user.getLanguage()));//基本信息
        groupItem.put("defaultshow", true);

        //模板文件
        ConditionFactory conditionFactory = new ConditionFactory(user);
        searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet");
        searchConditionItem.setValue(filePath);
        itemList.add(searchConditionItem);

        //Excel文件
        searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile");
        itemList.add(searchConditionItem);

        groupItem.put("items", itemList);
        groupList.add(groupItem);

        /*导入说明*/
        Map<String, Object> itemMap = null;
        itemList = new ArrayList<Object>();
        groupItem = new HashMap<String, Object>();
        groupItem.put("title", SystemEnv.getHtmlLabelName(33803, user.getLanguage()));
        groupItem.put("defaultshow", true);

        /*请先下载模板*/
        itemMap = new HashMap<String, Object>();
        itemMap.put("index", 0);
        itemMap.put("value", SystemEnv.getHtmlLabelName(383083, user.getLanguage()));
        itemMap.put("link", filePath);
        itemList.add(itemMap);

        /* 填写模板数据后将文件上传。 */
        itemMap = new HashMap<String, Object>();
        itemMap.put("index", 1);
        itemMap.put("value", SystemEnv.getHtmlLabelName(125452, user.getLanguage()));
        itemList.add(itemMap);

        /*【考勤组】是必填列，请填写考勤组的名称*/
        itemMap = new HashMap<String, Object>();
        itemMap.put("index", 2);
        itemMap.put("value", SystemEnv.getHtmlLabelName(390304, user.getLanguage()));
        itemList.add(itemMap);

        /*【日期】列是必填列，日期格式为yyyy-MM-dd*/
        itemMap = new HashMap<String, Object>();
        itemMap.put("index", 3);
        itemMap.put("value", SystemEnv.getHtmlLabelName(389753, user.getLanguage()));
        itemList.add(itemMap);

        /*【类型】列是必填列，只能选择公众假日、调配工作日、调配休息日中的一种，当选择类型为调配工作日时，【对应工作日】必须选择一个工作日*/
        itemMap = new HashMap<String, Object>();
        itemMap.put("index", 4);
        itemMap.put("value", SystemEnv.getHtmlLabelName(389754, user.getLanguage()));
        itemList.add(itemMap);

        /* 【对应工作日】列只当【类型】列选择“调配工作日”时才需要选择 */
        itemMap = new HashMap<String, Object>();
        itemMap.put("index", 5);
        itemMap.put("value", SystemEnv.getHtmlLabelName(389992, user.getLanguage()));
        itemList.add(itemMap);

        /* 暂时不支持为排班制的考勤组设置节假日 */
        itemMap = new HashMap<String, Object>();
        itemMap.put("index", 6);
        itemMap.put("value", SystemEnv.getHtmlLabelName(526272, user.getLanguage()));
        itemList.add(itemMap);

        groupItem.put("items", itemList);
        groupList.add(groupItem);
        resultMap.put("condition", groupList);
        resultMap.put("status", "1");
        return resultMap;
    }
}
