package com.engine.kq.cmd.attendanceButton;

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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

/**
 * 外勤记录 查询条件
 */
public class GetOutButtonConditionCmd extends AbstractCommonCommand<Map<String, Object>> {
  private HttpServletRequest request;

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

	@Override
	public Map<String, Object> execute(CommandContext commandContext) {
		Map<String, Object> retmap = new HashMap<String, Object>();
		try{
      List<Object> lsCondition = new ArrayList<Object>();
      List<SearchConditionOption> selOptions = null;
      String[] options = null;

      HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
      SearchConditionItem searchConditionItem = null;

      HrmFieldBean hrmFieldBean = new HrmFieldBean();
      hrmFieldBean.setFieldname("typeselect");
      hrmFieldBean.setFieldlabel("19482");
      hrmFieldBean.setFieldhtmltype("3");
      hrmFieldBean.setType("2");
      hrmFieldBean.setIsFormField(true);
      hrmFieldBean.setViewAttr(2);
      hrmFieldBean.setIsFormField(false);
//      hrmFieldBean.setFieldvalue(awardDate);
      searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
      lsCondition.add(searchConditionItem);

      hrmFieldBean = new HrmFieldBean();
      hrmFieldBean.setFieldname("signtypecondition");
      hrmFieldBean.setFieldlabel("25996");
      hrmFieldBean.setFieldhtmltype("5");
      hrmFieldBean.setType("1");
      hrmFieldBean.setIsFormField(true);
      selOptions = new ArrayList<>();
      selOptions.add(new SearchConditionOption("0",SystemEnv.getHtmlLabelName(332, user.getLanguage()),true));
      selOptions.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(82634, user.getLanguage())));
      selOptions.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(386502, user.getLanguage())));
      hrmFieldBean.setSelectOption(selOptions);
      hrmFieldBean.setFieldvalue("0");
      searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
      searchConditionItem.setLabelcol(3);
      searchConditionItem.setFieldcol(20);
      searchConditionItem.setViewAttr(2);

      lsCondition.add(searchConditionItem);

      retmap.put("conditions", lsCondition);
      retmap.put("status", "1");
    }catch (Exception e) {
      retmap.put("status", "-1");
      retmap.put("message",  SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
			writeLog(e);
		}
		return retmap;
	}

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

}
