package nccloud.web.hrwa.waruleex.action;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;

import nc.itf.hr.wa.IWaRuleExService;
import nc.vo.hrwa.waruleex.AggWageformExVO;
import nc.vo.hrwa.waruleex.WageformExVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.uif2.LoginContext;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.container.IRequest;
import nccloud.web.hr.pub.HRCommonAction;
import nccloud.web.hr.pub.HRNccUtils;
import nccloud.web.uapbd.commons.web.ParamUtils;

/**
 * 启用停用按钮功能
 * @date 2021-4-8 08:47:21
 * @author chenzhfa
 *
 */
public class WaRuleExEnableAction extends HRCommonAction{

	@Override
	public <T> Object execute(IRequest request, T para) throws Exception {
		ParamUtils param = new ParamUtils(request);
		LoginContext context = HRNccUtils.getLoginContext(param);
		String pkWaWageformex = param.getString("pk_wa_wageformex", null);
		String enable = param.getString("isenable", null);
		WaRuleExCommon common = new WaRuleExCommon();
		AggWageformExVO aggWageformExVO = common.listHandleData(context, pkWaWageformex);
		
		Boolean isenable = Boolean.FALSE;
		if("Y".equals(enable)) {
			isenable = Boolean.TRUE;
		} else {
			isenable = Boolean.FALSE;
		}
		
		WageformExVO wageformExVO = (WageformExVO) aggWageformExVO.getParentVO();
		
		int rst = ServiceLocator.find(IWaRuleExService.class).updateEnable(pkWaWageformex, isenable);
		List<AggWageformExVO> returnList = new ArrayList();
		String pk="";
		boolean val = true;
		if(rst > 0) {
			pk = pkWaWageformex;
		}
		String msg = "";
		if(rst > 0) {
			pk = pk;
		} else {
			val = false;
			msg = "操作失败，请检查！";
		}
		JSONObject json = new JSONObject();
		json.put("message", msg);
		json.put("success", val);
		json.put("pk", pk);
		return json;
	}

}
