package com.engine.kq.cmd.importlog;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

import java.util.HashMap;
import java.util.Map;

public class SaveImportDeitalLogCmd extends AbstractCommonCommand<Map<String, Object>>{
	
	public SaveImportDeitalLogCmd(Map<String, Object> params, User user) {
		this.user = user;
		this.params = params;
	}

	@Override
	public Map<String, Object> execute(CommandContext commandContext) {
		Map<String, Object> retmap = new HashMap<String, Object>();
		String sql = "";
		RecordSet rs = new RecordSet();
		try {
			String pId = Util.null2String(this.params.get("pId"));
			String lineNum = Util.null2String(this.params.get("lineNum"));
			String relatedName = Util.null2String(this.params.get("relatedName"));
			String msg = Util.null2String(this.params.get("msg"));
			String status = Util.null2String(this.params.get("status"));
			sql = " insert into hrmimporthistoryDetail (pid,rownums,relatedName,operateDetail,status)" +
					  " values("+pId+","+lineNum+",'"+relatedName+"','"+msg+"','"+status+"') ";
			rs.executeSql(sql);
			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() {
		// TODO Auto-generated method stub
		return null;
	}
}
