package com.engine.kq.cmd.hrmAttProcSet;

import com.api.hrm.util.PageUidFactory;
import com.cloudstore.dev.api.util.Util_TableMap;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import java.util.HashMap;
import java.util.Map;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

/**
 * 获取考勤流程设置 校验规则列表
 * @author pzy
 *
 */
public class GetStateProcSetFlowCheckRuleListCmd extends AbstractCommonCommand<Map<String, Object>>{

	public GetStateProcSetFlowCheckRuleListCmd(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>();
    try {
      String type = Util.null2String(params.get("type"));
      String id = Util.null2String(params.get("id"));
      String attid = Util.null2s(Util.null2String(params.get("attid")),"");
      if(attid.length() == 0){
        retmap.put("status", "-1");
        retmap.put("message", SystemEnv.getHtmlLabelName(500682, user.getLanguage()));
        return retmap;
      }

      String backfields = " * ";
      String fromSql  = " (   select a.*,b.labelids,b.rule_table,b.uuid a_uuid,b.uuid b_uuid,b.uuid c_uuid from kq_att_checkrule_set a left join kq_att_checkrule_type b on a.rule_type_uuid=b.uuid) f ";
      String sqlWhere = " where 1=1 ";
      sqlWhere += " and attid = "+attid;
      String orderby = " id " ;
      String tableString = "";

      //操作字符串
      String  operateString= "";
      operateString = "<operates width=\"20%\">";
      operateString+="     <operate href=\"javascript:doEdit();\" text=\""+SystemEnv.getHtmlLabelName(93,user.getLanguage())+"\" index=\"0\"/>";
      operateString+="     <operate href=\"javascript:doDelete()\" text=\""+SystemEnv.getHtmlLabelName(23777,user.getLanguage())+"\" index=\"1\"  />";
      operateString+="</operates>";
      String tabletype="checkbox";
      String pageUid = PageUidFactory.getHrmPageUid("StateProcSetFlowCheckRuleList");

      tableString =" <table pageUid=\""+pageUid+"\" tabletype=\""+tabletype+"\" pagesize=\"10\" >"+
          "	   <sql backfields=\""+backfields+"\" sqlform=\""+fromSql+"\" sqlwhere=\""+Util.toHtmlForSplitPage(sqlWhere)+"\"  sqlorderby=\""+orderby+"\"  sqlprimarykey=\"id\" sqlsortway=\"desc\" sqlisdistinct=\"false\"/>"+
          operateString+
          "			<head>"+
          "				<col width=\"0%\"   hide=\"true\" column=\"id\" />"+
          "				<col width=\"50%\"  text=\""+SystemEnv.getHtmlLabelName(516077,user.getLanguage()) +"\" column=\"labelids\" orderkey=\"labelids\" transmethod=\"com.engine.kq.util.KQTransMethod.getCheckRuleName\" otherpara=\""+user.getLanguage()+"\" />"+
          "				<col width=\"50%\"  text=\""+SystemEnv.getHtmlLabelName(83194,user.getLanguage()) +"\" column=\"a_uuid\" orderkey=\"a_uuid\" otherpara=\"column:ruleid+column:rule_table+check_rule+"+user.getLanguage()+"\"  transmethod=\"com.engine.kq.util.KQTransMethod.get_rules\" />"+
          "				<col width=\"50%\"  text=\""+SystemEnv.getHtmlLabelName(127151,user.getLanguage()) +"\" column=\"b_uuid\" orderkey=\"b_uuid\" otherpara=\"column:ruleid+column:rule_table+check_level+"+user.getLanguage()+"\"  transmethod=\"com.engine.kq.util.KQTransMethod.get_rules\" />"+
          "				<col width=\"50%\"  text=\""+SystemEnv.getHtmlLabelName(33141,user.getLanguage()) +"\" column=\"c_uuid\" orderkey=\"c_uuid\" otherpara=\"column:ruleid+column:rule_table+check_message+"+user.getLanguage()+"\"  transmethod=\"com.engine.kq.util.KQTransMethod.get_rules\" />"+
          "			</head>"+
          " </table>";

      //主要用于 显示定制列以及 表格 每页展示记录数选择
      String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
      Util_TableMap.setVal(sessionkey, tableString);
      retmap.put("sessionkey", sessionkey);
      retmap.put("status", "1");
    } catch (Exception e) {
      retmap.put("status", "-1");
      retmap.put("message",  SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
      writeLog(e);
    }
    return retmap;
  }
	
}
