📜 ⬆️ ⬇️

Rapid Java Reporting Development: Downshifting from 1C: Enterprise

Greetings dear readers.

As promised in the first article, Rapid Development of CRUD in Java: Downshifting with 1C: Enterprise , I continue to describe my OpenSource projects that implement the functionality similar to 1C: Enterprise.

This time, this is ACS - a data composition system, and my development is FlexReporting ( link to GitHub ).
What is the essence of this mechanism? This is a kind of realtime - ROLAP tool that on the fly transforms “flat” data into hierarchical reports.
')
In fact, there are many lovers to argue that SKD is not a “true” OLAP, but I would remind that such a thing as aggregates that pre-calculate and store multidimensional data on all (or given) combinations of measurements of current accumulation registers - and this weighty argument for using this abbreviation. However, I would very much like to avoid controversy disputes.

This is how it looks in 1C ERP 2.0:



The functions of the ACS (and my development) are to give the user a data source, and even if he wants to play with the report settings:

1. Sets the sequence in which the data will be displayed, which groups will be vertically, which will be horizontal.
For example: warehouse, product, manager, etc.
2. Sets a set of indicators, and aggregate functions (sum, average, number, minimum, maximum, etc.) that will be applied to them.
For example: amount (value), average (quantity of goods), maximum (date of shipment).

In general, this can be achieved in Excel, using the functionality of pivot tables, but in the base case it would be nice to have it in your own system if you intend to generate flexible reports from it. What I did, inventing another bicycle in freelance - as usual I did not find a simple and functional solution for this task right away, and time was running out.

I'll tell you about the algorithms.

For a start, let's define the data. They can be any - come from JDBC, ORM, via JSON or SOAP, as long as they can be converted to an ArrayList. The getData () function in the demo is a simple stub of several entries.

The user sets a set of configuration groups that will be displayed in the report. Then 2 trees are built on them (horizontal and vertical groupings).
groupsFeildsList.add ("a");
groupsFeildsList.add ("b, bb");
groupsFeildsList.add ("url");
columnFeildsList .add ("c");

The problem is that the user may want to see a combination of fields on the same grouping level (in the example b and bb). This complicated the algorithm somewhat, before it was more readable.

Next, we establish a list of indicators, and an aggregate function that works on them (in the demo one indicator):
computeFeildsList.add (newHashMap ("field, function", "d", "max"));

According to our data, the recursive functions of generate (vert, t, groupsFeildsList, 0) form the trees described by the simplest Node class:
public class Node implements Cloneable {
public ArrayList / Node / nodes;
public LinkedHashMap fields;
public HashMap additional;
public Node parent;
...
};

Next, the indicators are calculated by tree level, of course, also recursive - the public HashMap compute function (Node x, Node y, ArrayList t, ArrayList computeFeildsList) and the simultaneous output of the result in html.

All this miracle works under Spring and is inserted into the jsp template. There were a couple of slippery moments with him.
The report was supposed to be interactive. On the Internet, I found an example - jsfiddle.net/NZaw4/10 .
Since I decided to use styles for folding and expanding rows a la Excel, they had to be loaded somehow. There were problems with this, and in the end I stuck the text directly into the jsp template (style type = “text / css”).

Another point: it turned out that different browsers work differently with checkboxes, as a result you may notice such a thing in the code:
if (((ua.indexOf ('MSIE')! = -1) || (ua.indexOf ('Firefox')! = -1) || (ua.indexOf ('Mozilla')! = -1)) && (ua.indexOf ('Chrome') == -1)) {
row.querySelector ('td input'). checked =! row.querySelector ('td input'). checked;
newch =! row.querySelector ('td input'). checked;
}

Actually, this is what happened with me:


What I would like to add. In the first article, I received some practical advice, and links to resources that are worth studying. Thank you very much for this.

But he received a bit of negativity, with an emphasis on the fact that, say 1C, these developments on the knee will never be caught up (and not forced out of the regular reporting niche), and in general all this is just a languor of spirit and vanity. Naturally not to catch up! Therefore, the source code is open, because several other goals were set.

Nevertheless, I will inform one interesting fact. That week I had a chance to speak at the INFOSTART EVENT 2015 CONNECTION conference at the “Colosseum” in St. Petersburg.

And what did I see there?

2 reports on open projects with a similar focus:
1script
This project is an alternative implementation of a virtual machine that executes scripts in 1C: Enterprise.
At the same time, the project is completely independent of 1C libraries and does not require the presence of the 1C: Enterprise system on the target machine.

Metadata.js
This is an alternative light javascript 1C client that allows you to read and edit data located on a 1C server with a large number of connections (dealers or an online storefront with hundreds of anonymous or authorized external users).


So not one, I have specific tastes, there are many of us.



Have a good working week everyone!

Source: https://habr.com/ru/post/269505/


All Articles