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;

/**
 * 工作日期调整升级
 * @author pzy
 *
 */
public class DoUpgrade4Cmd extends AbstractCommonCommand<Map<String, Object>>{

	public DoUpgrade4Cmd(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 {
		  KQOneStopUp kqOneStopUp = new KQOneStopUp();
      kqOneStopUp.clearPub();
		  kqOneStopUp.upPub();

      Map<String,Object> pubmap = new HashMap<String,Object>();
      List<Object> pubList = new ArrayList<>();

		  String getPubSql = "select * from KQ_HOLIDAYSET where id in(select kqid from hrm_to_kq_pub) ";
      rs.executeQuery(getPubSql);
      while (rs.next()){
        String holidaydate = rs.getString("holidaydate");
        String holidaydesc = rs.getString("holidaydesc");
        String changetype = rs.getString("changetype");
//        1-公众假日、2-调配工作日、3-调配休息日
        String changetypeDesc = "1".equals(changetype)?"公众假日":("2".equals(changetype)?"调配工作日":"调配休息日");
        String desc = holidaydate+" "+holidaydesc+"("+changetypeDesc+")";
        pubList.add(desc);
      }
      pubmap.put("label", SystemEnv.getHtmlLabelName(10000841,weaver.general.Util.getIntValue(user.getLanguage())));
      pubmap.put("status", "1");
      pubmap.put("results", pubList);
      items.add(pubmap);

      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;
	}

}
