package com.engine.kq.cmd.upgrade;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQOneStopUp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import weaver.workflow.workflow.WorkflowComInfo;

/**
 * 考勤流程设置升级
 * @author pzy
 *
 */
public class DoUpgrade8Cmd extends AbstractCommonCommand<Map<String, Object>>{

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

	@Override
	public BizLogContext getLogContext() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Map<String, Object> execute(CommandContext commandContext) {
		Map<String,Object> retmap = new HashMap<String,Object>();
    List<Object> items = new ArrayList<>();
    RecordSet rs = new RecordSet();
    RecordSet rs1 = new RecordSet();
		try {
      WorkflowComInfo workflowComInfo = new WorkflowComInfo();
		  KQOneStopUp kqOneStopUp = new KQOneStopUp();
      kqOneStopUp.clearAttSet();
		  kqOneStopUp.upAttSet();

      Map<String,Object> attSetmap = new HashMap<String,Object>();
      List<Object> attSetList = new ArrayList<>();

      String getAttSetSql = "select* from kq_ATT_PROC_SET where id in(select kqid from hrm_to_attSet) ";
      rs.executeQuery(getAttSetSql);
      while (rs.next()){
        String workflowname = workflowComInfo.getWorkflowname(rs.getString("field001"));
        attSetList.add(workflowname);
      }
      attSetmap.put("label", SystemEnv.getHtmlLabelName(10000845,weaver.general.Util.getIntValue(user.getLanguage())));
      attSetmap.put("status", "1");
      attSetmap.put("results", attSetList);
      items.add(attSetmap);

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

}
