Disclosure of Invention
In view of the above, an object of the present application is to provide a data processing method and apparatus, a server device and a storage medium, so as to solve the problems in the prior art.
In order to achieve the above purpose, the embodiment of the present application adopts the following technical solutions:
in a first aspect, the present invention provides a data processing method, where the data processing method is applied to a server device, and the server device is in communication connection with a client device, where the data processing method includes:
acquiring at least one CAD file to be processed;
extracting the at least one computer aided design file to obtain at least one scalable vector graphic, and storing the at least one scalable vector graphic;
and sending the corresponding scalable vector graphics to the client equipment according to the request of the client equipment.
In an alternative embodiment, the step of extracting the at least one computer-aided design file to obtain at least one scalable vector graphics includes:
analyzing the computer aided design file to obtain basic primitive data of the computer aided design file;
and converting the basic primitive data to obtain the scalable vector graphics.
In an optional embodiment, the step of analyzing the computer-aided design file to obtain basic primitive data of the computer-aided design file includes:
processing the computer aided design file to obtain all primitive data of the computer aided design file;
and filtering all the primitive data to obtain basic primitive data.
In an optional embodiment, the step of performing conversion processing on the basic primitive data to obtain a scalable vector graphics includes:
generating scalable vector graphics nodes from the base primitive data;
and filling the scalable vector graph nodes to obtain the scalable vector graph.
In an optional embodiment, the step of performing padding processing on the scalable vector graphics node to obtain a scalable vector graphics includes:
reading the basic primitive data to obtain a data object;
and writing the data object into the scalable vector graphics node to obtain the scalable vector graphics.
In an alternative embodiment, the step of sending the corresponding scalable vector graphics to the client device according to the request of the client device includes:
acquiring request information sent by the client equipment;
and selecting a corresponding scalable vector graphic from the at least one scalable vector graphic according to the request information and sending the scalable vector graphic to the client device.
In an optional embodiment, the data processing method further includes:
acquiring operation data of the client device on the scalable vector graphics;
and updating the stored at least one scalable vector graphics according to the operation data.
In a second aspect, the present invention provides a data processing apparatus, where the data processing apparatus is applied to a server device, and the server device is in communication connection with a client device, and the data processing apparatus includes:
the file acquisition module is used for acquiring at least one computer aided design file to be processed;
the extraction processing module is used for extracting the at least one computer aided design file to obtain at least one scalable vector graphic and storing the at least one scalable vector graphic;
and the sending module is used for sending the corresponding scalable vector graphics to the client equipment according to the request of the client equipment.
In a third aspect, the present invention provides a server device, including: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the data processing method of any one of the preceding embodiments when executing the program.
In a fourth aspect, the present invention provides a storage medium, where the storage medium includes a computer program, and the computer program controls, when running, a server device in which the storage medium is located to execute the data processing method according to any one of the foregoing embodiments.
According to the data processing method and device, the server device and the storage medium, the server device extracts and processes the computer aided design file to obtain at least one scalable vector graph, and sends the corresponding scalable vector graph to the client device according to the request of the client device, so that the server device draws the CAD file into the SVG, and the problems that in the prior art, the client analyzes data to calculate and draw, the performance is very high, a large amount of data cannot be processed, page blocking is unavailable, and the efficiency of data processing is low are solved.
Detailed Description
At present, special CAD manufacturing software is required to be installed for viewing and operating CAD drawing files in the industry. However, such software is generally bulky and has a high requirement on the performance of the device, so that the CAD cannot be edited and smoothly viewed on devices with low performance, such as a mobile phone or a PAD, because the software is currently only in a PC computer version.
The first scheme in the prior art is as follows: the CAD file is analyzed through the server side, the obtained original data are sent to the client side, the client side analyzes the data through an appointed format and draws the data into canvas to a browser, and viewing is achieved. Comparative disadvantages: CAD content cannot be edited, and canvas drawing processing data mode is complex.
Scheme two in the prior art: and embedding drawing browsing controls of various manufacturers in the HTML file to realize browsing drawings in different CAD formats. Comparative disadvantages: the integration of the manufacturer drawing browsing control into the browser is not practical, the browser control of a single manufacturer ranges from dozens of Mb to hundreds of Mb, and the browser is difficult to embed more such controls.
Scheme three in the prior art: the CAD file is analyzed through the server side, the obtained original data are sent to the client side, the client side analyzes the data through an appointed format and draws the data into svg to a browser, and checking is achieved. Comparative disadvantages: the client analyzes the data for calculation and drawing, the performance is consumed, a large amount of data cannot be processed, and the page is unsmooth and unavailable.
In order to improve at least one of the above technical problems proposed by the present application, embodiments of the present application provide a data processing method and apparatus, an electronic device, and a storage medium, and the following describes technical solutions of the present application through possible implementation manners.
The defects existing in the above solutions are the results obtained after the inventor has practiced and studied carefully, so the discovery process of the above problems and the solutions proposed by the embodiments of the present application in the following description to the above problems should be the contributions made by the inventor in the invention process.
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It is to be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
It should be noted that the features of the embodiments of the present application may be combined with each other without conflict.
Fig. 1 is a block diagram of a data processing system 10 provided in an embodiment of the present application, which provides a possible implementation manner of the data processing system 10, and referring to fig. 1, the data processing system 10 may include one or more of a server device 100 and a client device 200.
Therein, the server device 100 is communicatively connected with the client device 200 to transmit the corresponding scalable vector graphics to the client device 200 according to the request of the client device 200.
Optionally, specific types of the server device 100 and the client device 200 are not limited, and may be set according to actual application requirements. For example, in an alternative example, the server device 100 and the client device 200 may be different devices, with the server service deployed on the server device 100 and the client service deployed on the client device 200. The server device 100 serves the client device 200, and the content of the service such as providing resources to the client device 200, saving client data, and the like. The client device 200 may be any computer, and may use the service provided by the server device 100 as long as the client device is connected to the server device 100 and authorized by the server device 100. The client service refers to a program corresponding to the server service and providing local service for the client, and is generally installed on a common client except some application programs which are only operated locally, and needs to be operated in cooperation with the server service.
For another example, in another alternative example, the server device 100 and the client device 200 may be the same device.
Referring to fig. 2, a block diagram of a server device 100 according to an embodiment of the present disclosure is shown, where the server device 100 in this embodiment may be a server, a processing device, a processing platform, and the like capable of performing data interaction and processing. The server device 100 includes a first memory 110, a first processor 120, and a communication module 130. The elements of the first memory 110, the first processor 120 and the communication module 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines.
The first memory 110 is used for storing programs or data. The first Memory 110 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like.
The first processor 120 is used to read/write data or programs stored in the first memory 110 and perform corresponding functions. The communication module 130 is used for establishing a communication connection between the server device 100 and another communication terminal through a network, and for transceiving data through the network.
It should be understood that the structure shown in fig. 2 is only a schematic structural diagram of the server device 100, and the server device 100 may also include more or less components than those shown in fig. 2, or have a different configuration than that shown in fig. 2. The components shown in fig. 2 may be implemented in hardware, software, or a combination thereof.
Fig. 3 shows one of flowcharts of a data processing method provided in the embodiment of the present application, where the method is applicable to the server device 100 shown in fig. 2 and is executed by the server device 100 in fig. 2. It should be understood that, in other embodiments, the order of some steps in the data processing method of this embodiment may be interchanged according to actual needs, or some steps may be omitted or deleted. The flow of the data processing method shown in fig. 3 is described in detail below.
Step S310, at least one CAD file to be processed is obtained.
Step S320, performing extraction processing on at least one computer aided design file to obtain at least one scalable vector graphics, and storing the at least one scalable vector graphics.
Step S330, the corresponding scalable vector graphics is transmitted to the client device 200 according to the request of the client device 200.
According to the method, the server side equipment extracts the computer aided design file to obtain at least one scalable vector graph, and sends the corresponding scalable vector graph to the client side equipment according to the request of the client side equipment, so that the CAD file is drawn into the SVG by the server side equipment, and the problems that in the prior art, the client side analyzes data to calculate and draw, the performance is very high, a large amount of data cannot be processed, page blockage is unavailable, and the data processing efficiency is low are solved.
For step S310, it should be noted that Computer Aided Design (CAD) refers to a method for creating and simulating a physical Design by using a Computer and its graphic device. The following CAD drawings may refer to files produced by CAD production software, including but not limited to files of the types dxf, dwg. That is, the computer aided design file in the embodiment of the present application may be a DXF file. In connection with fig. 4, the DXF file may include different segments (specifically, a header segment, a class segment, a table segment, a block segment, a real segment, an object segment, and an end segment), different segments may include different groups, and different groups may include different group codes.
For step S320, it should be noted that the specific way of performing the extraction process is not limited, and may be set according to the actual application requirement. For example, in an alternative example, step S320 may include the steps of performing the parsing process and then the conversion process. Therefore, on the basis of fig. 3, fig. 5 is a schematic flowchart of another data processing method provided in the embodiment of the present application, and referring to fig. 5, step S320 may include:
step S321, analyzing the CAD file to obtain the basic primitive data of the CAD file.
Step S322, the basic primitive data is converted to obtain the scalable vector graphics.
For step S321, it should be noted that the specific manner of performing the parsing process is not limited, and may be set according to the actual application requirement. For example, in an alternative example, step S321 may include the following sub-steps:
processing the computer aided design file to obtain all primitive data of the computer aided design file; and filtering all the primitive data to obtain basic primitive data.
In detail, the server can analyze the CAD file by using a custom-packaged JAVA code library, analyze all primitive data in the CAD, clean, filter and sort the data to obtain a classified and summarized data structure (basic primitive data) capable of being operated quickly, and finally store the data structure into a database.
Among them, JAVA is a widely used computer programming language, has the characteristics of cross-platform, object-oriented, and generic programming, and is widely applied to enterprise-level Web application development and mobile application development.
Optionally, the specific manner of the filtering process is not limited, and may be set according to actual requirements. For example, in an alternative example, all primitive data may be subjected to compatible error correction processing, garbage filtering processing, custom data type encapsulation processing, and scrambling processing to obtain basic primitive data.
For example, a simple straight line is taken as an example: opening the DXF file and reading the data in the entites (entity segment) can obtain the following data (information of a straight line).
The straight line type data structure is then generated as follows:
JSON
{
type:"line",
start:[39443547.70425819,3380656.167584735],
end:[39443550.59516326,3380653.218246026],
width:1,
color:"#000000"
}
that is, the primitive data obtained in the above steps represents a straight line having a starting point (x:39443547.70425819, y:3380656.167584735) and an ending point (x:39443550.59516326, y:3380653.218246026) with a width of 1, and the data are stored in the database.
For step S322, it should be noted that the specific manner of performing the conversion processing is not limited, and may be set according to the actual application requirement. For example, in an alternative example, step S322 may include the following sub-steps:
generating scalable vector graphic nodes according to the basic primitive data; and filling the scalable vector graph nodes to obtain the scalable vector graph.
The specific way of filling is not limited, and can be set according to the actual application requirements. For example, in an alternative example, the step of performing the filling process may include the sub-steps of:
reading the basic primitive data to obtain a data object; and writing the data object into the scalable vector graphics node to obtain the scalable vector graphics.
And with reference to fig. 6, converting different types of modules in the basic primitive data into corresponding XML nodes in the SVG specification according to a preset algorithm rule, reading data objects in the basic primitive data modules to enrich and perfect the SVG nodes, and storing the XML data in a database after the processing is finished.
Optionally, the specific type of the data object is not limited, and may be set according to the actual application requirement. For example, in an alternative example, the data object may include, but is not limited to, graphical descriptions, coordinate points, textual information, and the like.
An Extensible Markup Language (XML) is a Markup Language that indicates information symbols that can be understood by computers, and documents containing various information can be handled between computers by the Markup.
Scalable Vector Graphics (SVG) is a Vector Graphics for describing two dimensions, which can be built based on XML markup language. As a text-based open network standard, SVG can gracefully and compactly render graphics of different sizes.
In the embodiment of the application, the XML structure of the SVG is converted according to the basic primitive data as follows:
for step S330, it should be noted that, the specific manner of sending the corresponding scalable vector graphics to the client device 200 according to the request of the client device 200 is not limited, and may be set according to the actual application requirement. For example, in an alternative example, step S330 may include the following sub-steps:
acquiring request information sent by client equipment 200; a corresponding scalable vector graphic is selected from the at least one scalable vector graphic according to the request information and transmitted to the client device 200.
In detail, the interaction process between the client and the server is as follows: when the client side wants to check the CAD drawing stored in the server side, a user starts a browser terminal, a client side website of the system is opened, the CAD drawing to be browsed is selected, a client side program initiates an htpp request to the server side, the server side receives XML data corresponding to the CAD drawing which is requested to be found, and the XML data are returned to the client side in a JSON character string mode.
After the client receives the request response, the XML structure is obtained from the JSON data through the defined data rule, then the client generates the XML structure of the character string into a node object of the SVG through the JS script, and inserts the node object into a certain node of the webpage for rendering and displaying. SVG is a vector marker, which can ensure smooth zooming and dragging preview on the premise of no distortion of the content.
The JS full-name JavaScript is a script and a programming language, can realize complex functions on a webpage, displays the content which is not simple static information any more but is updated in real time, and can be applied to interactive maps, 2D/3D animations, videos played in a rolling mode and the like.
JAVA is a widely used computer programming language, has the characteristics of cross-platform, object-oriented and generic programming, and is widely applied to enterprise-level Web application development and mobile application development.
It should be noted that if the SVG node does not perform processing, the functions of translation, dragging, and zooming on the web page cannot be realized. Therefore, after the SVG node is inserted into the web page, the SVG node needs to be obtained again, and is initialized through a section of js code processing, so as to obtain a js instance object (stored in the variable svgPanZoom), and after the initialization, functions such as dragging and zooming can be realized.
With reference to fig. 7, after the client device 200 acquires the XML string from the JSON data sent by the server device 100, the XML string may be converted into an XML node object of SVG, and after the event binding and node style adjustment processing are performed, it is determined whether a node already exists, if so, the node under the parent container is removed, and the js instance object stored in the variable svgPanZoom is destroyed; if not, calling a function appndchild () to insert the parameter node into a container node in the webpage, initializing a variable svgPanZoom () and realizing the function of dragging and translating. Where the function apendchild () is a function name of js, calling this function may insert the incoming parameter node into the specified node of the web page. Apendchild (sub) denotes, for example, inserting the sub node into the fast node.
Further, after step S330, the data processing method provided in the embodiment of the present application may further include the following sub-steps:
acquiring operation data of the client device 200 on the scalable vector graphics; and updating the stored at least one scalable vector graphics according to the operation data.
In detail, after the client renders the SVG node into the page, the client can bind the processing event through the JS script to operate the SVG node. After each operation is finished, the client side initiates the instruction type and the modification data of the corresponding operation to the server side through the http protocol, and the server side receives the instruction to edit the XML information stored in the database, so that the data synchronization of the client side and the server side is finished.
With reference to fig. 8, the present application provides a method and a software system for smoothly viewing and operating a large CAD file in a web browser of various devices, where the system includes a server written based on JAVA and a client written based on JS, and the server reads the CAD file to generate a data object (including a graphic description, a coordinate point, text information, etc.) with a specific data structure, and processes the original data object into XML structure data in SVG format for storage. When the client side initiates a request, the server side transmits corresponding XML structure data to the client side in a JSON character string mode, the client side receives the data and directly analyzes the data to generate an SVG object and draws the SVG object to a browser, and the JS script operates the CAD object through obtaining the SVG node and synchronizes to the server side.
By the method, the convenience of checking and operating the CAD file is greatly improved, the CAD file can be accessed on a mobile phone/PAD/PC computer at any time, and huge editing software does not need to be installed. And moreover, a large CAD file with the volume of hundreds of megabytes can be accessed at a browser end, and the experience is smooth and fluent. The SVG node generation algorithm in the embodiment of the application is processed at the server side, and the result is stored in the database, so that the performance overhead is saved when a browser accesses the SVG node generation algorithm. The embodiment of the application can also provide an online management function of the CAD graph, the latest state of the drawing can be dynamically checked, in the prior art, users all take single CAD files, and if the CAD files are modified, the cost of synchronizing to each party is extremely high, and management is inconvenient.
With reference to fig. 9, an embodiment of the present application further provides a data processing apparatus 900, where the functions implemented by the data processing apparatus 900 correspond to the steps executed by the foregoing method. The data processing apparatus 900 may be understood as a processor of the server device 100, or may be understood as a component that is independent from the server device 100 or the processor and implements the functions of the present application under the control of the server device 100. The data processing apparatus 900 may include a file acquiring module 910, an extracting processing module 920, and a transmitting module 930.
The file acquiring module 910 is configured to acquire at least one cad file to be processed. In this embodiment of the application, the file obtaining module 910 may be configured to perform step S310 shown in fig. 3, and for relevant contents of the file obtaining module 910, reference may be made to the foregoing description of step S310.
And the extraction processing module 920 is configured to perform extraction processing on at least one computer-aided design file to obtain at least one scalable vector graphics, and store the at least one scalable vector graphics. In the embodiment of the present application, the extraction processing module 920 may be configured to perform step S320 shown in fig. 3, and reference may be made to the foregoing description of step S320 for relevant contents of the extraction processing module 920.
A sending module 930 configured to send the corresponding scalable vector graphics to the client device 200 according to the request of the client device 200. In this embodiment of the application, the sending module 930 may be configured to execute step S330 shown in fig. 3, and reference may be made to the foregoing description of step S330 for relevant contents of the sending module 930.
In addition, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program performs the steps of the data processing method.
The computer program product of the data processing method provided in the embodiment of the present application includes a computer-readable storage medium storing a program code, where instructions included in the program code may be used to execute steps of the data processing method in the above method embodiment, which may be referred to specifically in the above method embodiment, and are not described herein again.
To sum up, according to the data processing method and apparatus, the server device and the storage medium provided by the embodiment of the application, the server device extracts and processes the computer aided design file to obtain at least one scalable vector graphic, and sends the corresponding scalable vector graphic to the client device according to the request of the client device, so that the server device draws the CAD file into the SVG, and the problems that in the prior art, the client analyzes data to calculate and draw, the performance is very high, a large amount of data cannot be processed, page blocking is unavailable, and the efficiency of data processing is low are solved.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.