package nc.impl.sap.valid;

import com.alibaba.fastjson.JSON;

import nc.bs.dao.BaseDAO;
import nc.bs.logging.Logger;
import nc.itf.sap.valid.ISapItfValid;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.pub.sap.constant.SapConstants;
import nc.vo.sap.result.SAPResultVO;
/**
 * @Description: 接口启用校验
 * 
 * @author 谢文如 【碧桂园SAP专项】
 * @date 2018-4-4
 * @version with NC V6.3
 */
public class SapItfValidImpl implements ISapItfValid {

	@Override
	public String itfIsEnabled(String itfCode) {
		try {
			StringBuffer sqlstr = new StringBuffer("");
			sqlstr.append("select nvl(isstart, 0) isstart").append("\r\n");
			sqlstr.append("  from bgy_esbinfo").append("\r\n");
			sqlstr.append(" where nvl(dr, 0) = 0").append("\r\n");
			sqlstr.append("   and code = '"); 
			sqlstr.append(itfCode); 
			sqlstr.append("'"); 
			BaseDAO dao = new BaseDAO();
			Object obj = dao.executeQuery(sqlstr.toString(), new ColumnProcessor());
			if(obj==null || !"1".equals(obj.toString())){
				SAPResultVO sapResultVO = new SAPResultVO();
				sapResultVO.setBillid("");
				sapResultVO.setIssuccess(SapConstants.FAIL_TRANS);
				sapResultVO.setMsg("接口未启用："+itfCode);
				return JSON.toJSONString(sapResultVO);
			}
		} catch (Exception e) {
			Logger.error(e);
			e.printStackTrace();
		}
		return null;
	}

}
