简体   繁体   English

创建报告生成器

[英]Creating a Report Generator

I'm in Enterprise support and the product I work with has a large database. 我在企业支持中,并且我使用的产品具有大型数据库。 There isn't a great report generating tool within the program so we get a lot of custom report requests. 该程序中没有出色的报告生成工具,因此我们收到了许多自定义报告请求。 These are generally pretty manageable and we have a pretty big library of queries written in the past to dissect and modify to tailor to each individual client's needs. 这些通常是很容易管理的,并且我们拥有过去编写的相当大的查询库,以进行剖析和修改以适应每个客户的需求。 That being said, there's a couple problems with this: 话虽这么说,这有几个问题:

  1. It's needlessly time consuming. 不必要地浪费时间。
  2. A lot of of our techs don't have the SQL knowledge to do this. 我们的许多技术人员都不具备执行此操作的SQL知识。

I'd like to create a tool that will construct these queries, but don't really know how to approach the task (ideally it would pull the data and export it to a csv, but for now just writing the query would be fine). 我想创建一个可以构造这些查询的工具,但实际上并不知道如何处理该任务(理想情况下,它将提取数据并将其导出到csv,但现在只写查询就可以了) 。 I'm familiar with SQL, javascript and python. 我熟悉SQL,javascript和python。 If none of those would be ideal then I'll teach myself whatever is best for it as I go. 如果这些都不是理想的,那么我会自学成才。

Let's take this sample database: 让我们看一下这个示例数据库:

http://www.eclipse.org/birt/img/documentation/sample-database/ClassicModelsDBSchema.jpg http://www.eclipse.org/birt/img/documentation/sample-database/ClassicModelsDBSchema.jpg

Let's say a client submits a ticket saying: 假设一位客户提交了一张票证,上面写着:

'Please produce a report of all our orders ever. '请提供我们所有订单的报告。 Please include the order number, product ordered and its quantity, the product vendor, the date ordered, date we required it by, the actual date it was shipped, the sales rep who processed it and which office they were from.' 请提供订单号,订购的产品及其数量,产品供应商,订购日期,我们要求的日期,实际发货日期,处理该产品的销售代表以及他们来自哪个办公室。

There'd probably be a template somewhere, but someone would end up creating a query such as this: 某处可能有一个模板,但是最终有人会创建这样的查询:

select o.orderNumber, p.productName, od.quantityOrdered, p.productVendor, o.orderDate, o.requiredDate, o.shippedDate, e.firstname, e.lastname, of.city, of.officeCode
from 
Orders o 
JOIN OrderDetails od ON o.orderNumber = od.orderNumber 
JOIN Products p ON od.productCode = p.productCode 
JOIN Customers c on o.customerNumber = c.customerNumber 
JOIN Employees e on e.employeeNumber = c.salesRepEmployeeNumber
JOIN Offices of on of.officeCode = e.officeCode 

I'd like to create something where I can just input something like "order number, product name, quantity, vendor, date needed, date shipped, Sales Rep, city, office" and the where logic and have it spit out the proper query. 我想创建一个可以在其中输入“订单号,产品名称,数量,供应商,需要的日期,发货日期,销售代表,城市,办公室”以及where逻辑的东西,然后输入正确的查询。

I want to start small and just make something that can work with a small number of values from 3-4 of our most used tables. 我想从小做起,只做一些可以使用我们最常用表的3-4中的少量值的事情。 No where logic for the time being. 暂时没有逻辑。 It's an obviously simplistic program, but it seems like a good first attempt. 这显然是一个简单的程序,但这似乎是一个不错的尝试。

eg a program that can only handle customers, orders, orderDetails, and products. 例如,只能处理客户,订单,orderDetails和产品的程序。

Can someone point me in the right direction for how to even start this project? 有人可以指出正确的方向,甚至开始这个项目吗? At this point, I'm kinda just spinning around looking for something I can grab and dig into. 在这一点上,我有点想寻找可以抓取并挖掘的东西。

Don't overthink it. 不要想太多。

Put a web interface on the queries you already have, where you allow some of the inputs be parameterized [like customer]. 在已存在的查询上放置一个Web界面,在此您可以对某些输入进行参数化(例如客户)。 If you have the basic query, there are a variety of tools that will let you : 如果您有基本的查询,可以使用多种工具:

  • filter query results 过滤查询结果
  • add or remove columns in the returned data set 在返回的数据集中添加或删除列
  • search within results 在结果中搜索
  • export results 出口结果

Start with this, because this is a LOT easier than trying to create a tool to write your SQL for you. 首先,因为这比尝试创建一个为您编写SQL的工具要容易得多。 Have a human assemble the core queries and use freely available software tools to put a presentation layer on them. 人工组装核心查询,并使用免费的软件工具在其上放置表示层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM