package com.kingdee.eas.custom.gy.task;

import com.kingdee.bos.ctrl.kdf.table.IRow;
import com.kingdee.bos.rabbitmq.guava.Lists;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;
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 java.lang.String;
import java.util.List;

public class TaskFacadeControllerBean extends AbstractTaskFacadeControllerBean
{
    private static Logger logger =
        Logger.getLogger("com.kingdee.eas.custom.gy.task.TaskFacadeControllerBean");

    @Override
    protected void _taskExecute(Context ctx, String osfServiceName, String data) throws BOSException {
        System.out.println("TaskFacadeControllerBean._taskExecute:");
        super._taskExecute(ctx, osfServiceName, data);
        try {
            StringBuilder sql = new StringBuilder();
            sql.append(" select fpositionid,fadminorgid,fpersonid from T_HR_EmpOrgRelation where fassigntype=1 and fleffdt='2199-12-31 00:00:00' ");
            IRowSet rs = DbUtil.executeQuery(ctx, sql.toString());
            List<String> list = Lists.newArrayList();
            while (rs.next()) {
                String fpositionid = rs.getString("fpositionid");
                String fadminorgid = rs.getString("fadminorgid");
                String fpersonid = rs.getString("fpersonid");
                StringBuilder upd = new StringBuilder();
                upd.append("update T_HR_ATS_HOLIDAYLIMIT set fpositionid='"+fpositionid+"',fadminorgunitid='"+fadminorgid+"' where fproposerid='"+fpersonid+"'");
                System.out.println("TaskFacadeControllerBean._taskExecute:"+upd);
                DbUtil.execute(ctx,upd.toString());
            }
        }catch (Exception e){
            e.printStackTrace();
            throw new BOSException(e);
        }
    }
}