zoukankan      html  css  js  c++  java
  • eas之kingdeeUtils

        import java.sql.ResultSetMetaData;
        import java.sql.SQLException;
        import java.util.ArrayList;
        import java.util.List;
        
        import com.kingdee.bos.BOSException;
        import com.kingdee.bos.dao.IObjectPK;
        import com.kingdee.bos.dao.IObjectValue;
        import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
        import com.kingdee.bos.dao.query.SQLExecutorFactory;
        import com.kingdee.bos.framework.DynamicObjectFactory;
        import com.kingdee.bos.util.BOSObjectType;
        import com.kingdee.bos.util.BOSUuid;
        import com.kingdee.eas.tools.datatask.client.TemplateExport;
        import com.kingdee.jdbc.rowset.IRowSet;
        import com.kingdee.util.UuidException;
     
        /**
         * 常用金蝶工具类
         * @author luojiabao
         *
         */
        public class KingdeeUtils {
            /**
             * 执行SQL语句,对象装载为list
             * @throws BOSException
             * @throws SQLException
             */
            public static List<Object[]> executeSQL(String sql) throws BOSException, SQLException{
                List<Object[]> values=new ArrayList<Object[]>();
                IRowSet rs=SQLExecutorFactory.getRemoteInstance(sql).executeSQL();
                ResultSetMetaData rsmd=rs.getMetaData();
                while (rs.next()) {
                    int count=rsmd.getColumnCount();
                    Object[] objs=new Object[count];
                    for (int i = 1; i < count; i++) {
                        objs[i-1]=rs.getObject(i);
                    }
                    values.add(objs);
                }
                return values;
            }
            /**
             * 返回一个数据
             * @param sql
             * @return
             * @throws SQLException
             * @throws BOSException
             */
            public static Object returnOneData(String sql) throws BOSException, SQLException{
                if(sql!=null&&!sql.equals("")){
                    List<Object[]> list=executeSQL(sql);
                    if(list.size()>0){
                        return list.get(0)[0];
                    }else{
                        return null;
                    }
                }
                return sql;
            }
        
        /**
         * 动态获取Info对象
         * @throws BOSException
         */
        public static IObjectValue getInfo(String id) throws BOSException{
            IObjectValue objValue=null;
            if(id!=null && !"".equals(id)){
                BOSUuid uuid=BOSUuid.read(id);
                IObjectPK pk = new ObjectUuidPK(uuid);
                objValue=DynamicObjectFactory.getRemoteInstance().getValue(uuid.getType(),pk);
            }
            return objValue;
        }
        
        /**
         * 动态单据操作-->删除
         * @param id
         * @return
         * @throws BOSException
         */
        public static boolean delete(String id){
            try {
                BOSUuid uuid=BOSUuid.read(id);
                DynamicObjectFactory.getRemoteInstance().delete(uuid.getType(),new ObjectUuidPK(uuid));
                return true;
            } catch (UuidException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (BOSException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;
        }
        
        /**
         * 动态单据操作 新增
         * @param bosType
         * @param objValue
         * @return
         */
        public static boolean addNew(BOSObjectType bosType,IObjectValue objValue){
            try {
                DynamicObjectFactory.getRemoteInstance().addnew(bosType, objValue);
                return true;
            } catch (BOSException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;
        }
        
        /**
         * 动态单据操作 更新
         * @param id
         * @param objectValue
         * @return
         */
        public static boolean update(String id,IObjectValue objectValue){
            BOSUuid uuid=BOSUuid.read(id);
            IObjectPK pk=new ObjectUuidPK(uuid);
            try {
                DynamicObjectFactory.getRemoteInstance().update(uuid.getType(),pk,objectValue);
                return true;
            } catch (BOSException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;    
        }
        
        /**
         * 导出模板
         * @param number
         * @param sheet
         * @param path
         * @return
         */
        public static boolean templateExport(String number,String sheet,String path){
            try {
                TemplateExport te=new TemplateExport(number,sheet);
                te.export();
                return true;
            } catch (Exception e) {
                e.printStackTrace();
            }
            return false;
        }
        }
     
    承接钉钉定制;网站服务定制; 联系qq:1655119603
  • 相关阅读:
    反向映射和写时复制
    内存分析的好blog
    minicom使用
    tee的妙用
    网络带宽
    mem analyse
    linux 应用层常用API/命令
    ubuntu 库依赖问题
    Python基础学习笔记(一:hello world)
    第7章 取消与关闭
  • 原文地址:https://www.cnblogs.com/luojiabao/p/10963529.html
Copyright © 2011-2022 走看看