package com.kingdee.eas.hr.project.app;

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.util.BOSUuid;
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.ormapping.ObjectUuidPK;
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.hr.project.IProjectChange;
import com.kingdee.eas.hr.project.IProjectManagement;
import com.kingdee.eas.hr.project.ProjectChangeCollection;
import com.kingdee.eas.hr.project.ProjectChangeFactory;
import com.kingdee.eas.hr.project.ProjectChangeInfo;
import com.kingdee.eas.hr.project.ProjectManagementFactory;
import com.kingdee.eas.hr.project.ProjectManagementInfo;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.bos.metadata.entity.SelectorItemInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.framework.SystemEnum;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import java.lang.String;
import java.math.BigDecimal;

import com.kingdee.eas.framework.ObjectBaseCollection;

public class ProjectChangeControllerBean extends AbstractProjectChangeControllerBean
{
    /**
	 * 
	 */
	private static final long serialVersionUID = -6003020121491523509L;
	private static Logger logger =Logger.getLogger("com.kingdee.eas.hr.project.app.ProjectChangeControllerBean");
    
    /**
     * 审核通过
     */
    protected void _setAudited(Context ctx, BOSUuid billID) throws BOSException, EASBizException {
    	logger.info("***starting**************execute");
    	super._setAudited(ctx, billID);
    	//处理反写逻辑
    	
    	IProjectChange iProjectChange = ProjectChangeFactory.getLocalInstance(ctx);
    	
    	ProjectChangeInfo projectChangeInfo = iProjectChange.getProjectChangeInfo(new ObjectUuidPK(billID));
    	
    	ProjectManagementInfo changeProjectInfo = projectChangeInfo.getChangeProject();
    	
    	BigDecimal chaManDays = projectChangeInfo.getChaManDays();
    	BigDecimal oriManDays = projectChangeInfo.getOriManDays();
    	BigDecimal changedManDays = chaManDays.subtract(oriManDays);
    	
    
    	changeProjectInfo.setChangedManDays(changedManDays.ONE);
    	
    	BigDecimal totalPersonDays1 = changeProjectInfo.getTotalPersonDays();
    	BigDecimal totalPersonDays2 = totalPersonDays1.add(changedManDays);
    	changeProjectInfo.setTotalPersonDays(totalPersonDays2);
    	
    	IProjectManagement iProjectManagement = ProjectManagementFactory.getLocalInstance(ctx);
    	SelectorItemCollection sic=new SelectorItemCollection();
    	sic.add(new SelectorItemInfo("changedManDays"));
    	sic.add(new SelectorItemInfo("totalPersonDays"));
    	iProjectManagement.updatePartial(changeProjectInfo, sic);
    	logger.info("***end**************execute");
    }
}