package com.engine.kq.cmd.hrmAttProcSet;

import com.api.browser.bean.SearchConditionItem;
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 weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

/**
 * 获取考勤流程设置 流程概览信息
 * @author pzy
 *
 */
public class GetStateProcSetCreateFormCmd extends AbstractCommonCommand<Map<String, Object>>{

	public GetStateProcSetCreateFormCmd(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> retmap = new HashMap<String,Object>();
		 
		List<Object> lsGroup = new ArrayList<Object>();
		Map<String,Object> groupitem = null;
		List<Object> itemlist = null;
		try {

			String[] fields = new String[]{"title,15451,1,1","usedetail,18411,4,2"};
			
			HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
			SearchConditionItem searchConditionItem = null;
			HrmFieldBean hrmFieldBean = new HrmFieldBean();
			itemlist = new ArrayList<Object>();
      for(int i=0;i<fields.length;i++) {
        String[] fieldinfo = fields[i].split(",");
        hrmFieldBean.setFieldname(fieldinfo[0]);
        hrmFieldBean.setFieldlabel(fieldinfo[1]);
        hrmFieldBean.setFieldhtmltype(fieldinfo[2]);
        hrmFieldBean.setType(fieldinfo[3]);
        hrmFieldBean.setIsFormField(true);
        if("usedetail".equals(hrmFieldBean.getFieldname())){
          hrmFieldBean.setFieldlabel("18095,17463");
          hrmFieldBean.setFieldvalue("0");
        }
        searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
        itemlist.add(searchConditionItem);
      }

			
			groupitem.put("items", itemlist);
			lsGroup.add(groupitem);
			retmap.put("condition", lsGroup);
			retmap.put("status", "1");
		} catch (Exception e) {
			retmap.put("status", "-1");
			retmap.put("message",  SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
			writeLog(e);
		}
			
		return retmap;
	}
}
