package com.kingdee.eas.custom.expandassess.app;

import com.kingdee.bos.metadata.entity.*;
import com.kingdee.bos.metadata.query.util.CompareType;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.custom.expandassess.ExpandAssessInfo;
import org.apache.log4j.Logger;

import javax.ejb.*;
import java.rmi.RemoteException;

import com.kingdee.bos.*;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.rule.RuleExecutor;
import com.kingdee.bos.metadata.MetaDataPK;
//import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean;
import com.kingdee.bos.framework.ejb.AbstractBizControllerBean;
//import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.service.ServiceContext;
import com.kingdee.bos.service.IServiceContext;

import com.kingdee.eas.framework.CoreBillBaseCollection;
import com.kingdee.eas.framework.app.CoreBillBaseControllerBean;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.framework.SystemEnum;
import com.kingdee.eas.custom.expandassess.QuarterlyRatioInfo;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.custom.expandassess.QuarterlyRatioCollection;

import java.lang.String;

import com.kingdee.eas.framework.ObjectBaseCollection;

public class QuarterlyRatioControllerBean extends AbstractQuarterlyRatioControllerBean {
    private static Logger logger =
            Logger.getLogger("com.kingdee.eas.custom.expandassess.app.QuarterlyRatioControllerBean");

    @Override
    protected IObjectPK _save(Context ctx, IObjectValue model) throws BOSException, EASBizException {
        QuarterlyRatioInfo quarterlyRatioInfo = (QuarterlyRatioInfo) model;
        //校验
        verify(ctx, quarterlyRatioInfo);
        return super._save(ctx, model);
    }

    /**
     * 校验
     *
     * @param ctx
     * @param info
     * @throws BOSException
     * @throws EASBizException
     */
    protected void verify(Context ctx, QuarterlyRatioInfo info) throws BOSException, EASBizException {
        int year = info.getYear();//年份
        String id = null;
        if (info.getId() != null) {
            id = info.getId().toString();
        }
        FilterInfo filterInfo = new FilterInfo();
        FilterItemCollection filterItems = filterInfo.getFilterItems();
        filterItems.add(new FilterItemInfo("year", year));
        filterItems.add(new FilterItemInfo("id", id, CompareType.NOTEQUALS));
        if (_exists(ctx, filterInfo)) {
            throw new BOSException(year + "数据已经存在,请勿重复创建");
        }
    }


}