JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "SELECT * FROM bom_structures WHERE parent_assembly_id = ?"; List<BomStructure> bomStructureList = jdbcTemplate.query(sql,new Object[]{parentId},new RowMapper<BomStructure>() { @Override public BomStructure mapRow(ResultSet resultSet,int i) throws sqlException { BomStructure bomStructure = new BomStructure(); bomStructure.setAssemblyId(resultSet.getLong("assembly_id")); bomStructure.setParentAssemblyId(resultSet.getLong("parent_assembly_id")); bomStructure.setAlternateBomDesignator(resultSet.getString("alternate_bom_designator")); bomStructure.setEngineeringChange(resultSet.getString("engineering_change")); bomStructure.setDescription(resultSet.getString("description")); return bomStructure; } });以上代码中,dataSource 是一个 Spring 配置的数据源对象,可以通过它访问 Oracle 数据库。sql 是查询 bom\_structures 表数据的 sql 语句,其中 ? 是一个参数占位符,用于传递 parentId 参数。query 方法的第二个参数是一个 Object 数组,用于传递参数值。第三个参数是一个 RowMapper 对象,它将结果集中的每一行映射为一个 BomStructure 对象。 如果我们需要查询 bom\_structure\_components 表数据,可以使用类似的代码:
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "SELECT * FROM bom_structure_components WHERE assembly_item_id = ?"; List<BomStructureComponent> bomStructureComponentList = jdbcTemplate.query(sql,new Object[]{assemblyItemId},new RowMapper<BomStructureComponent>() { @Override public BomStructureComponent mapRow(ResultSet resultSet,int i) throws sqlException { BomStructureComponent bomStructureComponent = new BomStructureComponent(); bomStructureComponent.setAssemblyItemId(resultSet.getLong("assembly_item_id")); bomStructureComponent.setComponentItemId(resultSet.getLong("component_item_id")); bomStructureComponent.setComponentQuantity(resultSet.getDouble("component_quantity")); bomStructureComponent.setReferenceDesignator(resultSet.getString("reference_designator")); bomStructureComponent.setItemSequence(resultSet.getInt("item_sequence")); return bomStructureComponent; } });与查询 bom\_structures 表的代码相比,上述代码中 sql 语句以及 RowMapper 的实现都有所不同。 查询 bom\_resources 表的代码也类似:
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "SELECT * FROM bom_resources WHERE assembly_id = ?"; List<Bomresource> bomresourceList = jdbcTemplate.query(sql,new Object[]{assemblyId},new RowMapper<Bomresource>() { @Override public Bomresource mapRow(ResultSet resultSet,int i) throws sqlException { Bomresource bomresource = new Bomresource(); bomresource.setAssemblyId(resultSet.getLong("assembly_id")); bomresource.setResourceId(resultSet.getLong("resource_id")); bomresource.setResourceSequence(resultSet.getInt("resource_sequence")); bomresource.setResourceType(resultSet.getString("resource_type")); bomresource.setResourceCode(resultSet.getString("resource_code")); return bomresource; } });以上代码中,dataSource、parentId、assemblyItemId 和 assemblyId 都是需要根据具体的业务场景指定的参数。 除了直接查询 EBS 数据库表数据之外,我们还可以使用 EBS 的 Web Service 接口来访问 EBS 数据。EBS 的 Web Service 接口提供了许多常用的业务功能,如查询客户信息、创建销售订单、收货、发货等。使用 Java 访问 EBS 的 Web Service 接口,通常需要使用 WSDL 生成客户端代码,并使用 SOAP 进行通信。使用 Apache CXF 这样的 SOAP Web Service 框架可以大大简化编写客户端代码的过程。 以查询客户信息为例,以下是使用 CXF 和 SOAP 访问 EBS Web Service 的代码:
JaxWsProxyfactorybean factorybean = new JaxWsProxyfactorybean(); factorybean.setAddress("http://localhost:8000/oracle/apps/oiv/custExt/oa?wsdl"); factorybean.setServiceClass(BusinessService.class); BusinessService businessService = (BusinessService) factorybean.create(); CustomerExtInputParameters inputParameters = new CustomerExtInputParameters(); inputParameters.setorganizationCode("VISION"); inputParameters.setCustomerNumber("1001"); CustomerExtOutputParameters outputParameters = businessService.customerExtQuery(inputParameters); Customer customer = outputParameters.getCustomer();以上代码中,我们使用 JaxWsProxyfactorybean 创建一个代理对象,它的地址是 EBS Web Service 的 WSDL 地址。BusinessService 是一个自动生成的接口,它包含了客户端和服务器端使用的所有方法。我们通过代理对象调用 BusinessService 的 customerExtQuery 方法来查询客户信息。customerExtQuery 方法的参数是一个 CustomerExtInputParameters 对象,它包含了查询所需的参数值。方法的返回值是一个 CustomerExtOutputParameters 对象,从中可以获取到查询到的客户信息。 总之,Java 对接 Oracle EBS 是一项非常重要的技能,它可以帮助企业更好地使用 EBS 以及满足业务需求。本文介绍了一些常见的 Java 对接 Oracle EBS 的方法和技术,希望对读者有所启发。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。