package com.engine.kq.cmd.holidaySet;

import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.hrm.bean.HrmFieldBean;
import com.api.hrm.util.HrmFieldSearchConditionComInfo;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.filter.XssUtil;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

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

/**
 * 节假日设置--获取同步表单的数据
 */
public class GetSyncFormCmd extends AbstractCommonCommand<Map<String, Object>> {

    public GetSyncFormCmd(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>();
        HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
        SearchConditionItem searchConditionItem = null;
        HrmFieldBean hrmFieldBean = null;

//        XssUtil xssUtil = new XssUtil();

        hrmFieldBean = new HrmFieldBean();
        hrmFieldBean.setFieldname("syncGroupIds");//同步到考勤组--多选
        hrmFieldBean.setFieldlabel("390664");
        hrmFieldBean.setFieldhtmltype("3");
        hrmFieldBean.setType("mkqgroup");
        hrmFieldBean.setIsFormField(true);
        hrmFieldBean.setViewAttr(3);
        searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
        searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(529901, user.getLanguage()));
        searchConditionItem.setRules("required|string");
        Map<String,Object> dataMap = new HashMap<String,Object>();
//        dataMap.put("sqlWhere", xssUtil.put(" kqtype!=2 "));
        searchConditionItem.getBrowserConditionParam().setDataParams(dataMap);
        itemList.add(searchConditionItem);

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