Production data statistical method and system based on PLC, electronic equipment and storage medium

By adopting PLC-based production data statistics method in PLC equipment, the problem of single data and insufficient storage space when PLC equipment collects production data is solved, effectively manage and store data, and improve the readability and accuracy of data.

CN120010366APending Publication Date: 2025-05-16SHENZHEN COMWIN AUTOMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411939318.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

When collecting production data, existing PLC equipment has a single data and the on-site personnel obtain less data. PLC needs to collect a large amount of different types of production equipment data, resulting in insufficient data storage space.

Method used

Using PLC-based production data statistics method, the original equipment production data collected by PLC is obtained, stored in the cache module and recorded the timestamp, divided and stored in the daily and monthly report storage modules according to the data acquisition time, memory and time limit thresholds are set, and storage space is cleaned regularly to avoid excessive data occupancy of storage space.

Benefits of technology

Effectively manage and store production data, avoid the problem of insufficient storage space, provide a visual statistical result interface, and improve the readability and accuracy of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120010366A_ABST
    Figure CN120010366A_ABST
Patent Text Reader

Abstract

The invention provides a production data statistical method and system based on a PLC, electronic equipment and a storage medium, and the method comprises the steps: obtaining original equipment production data and collection time of production equipment controlled by the PLC, storing the original equipment production data and collection time in a cache module, recording a timestamp, dividing the original equipment production data and collection time into a daily report storage module and a monthly report storage module by the cache module according to the collection time, and storing the daily report storage module and the monthly report storage module; displaying the data according to dates and months; a cache memory threshold value and a data timeliness threshold value are set, and a storage space is cleaned out regularly, so that the storage space is prevented from being excessively occupied by data, and the persistent storage space is kept in an unoccupied space to store the data; according to user query conditions, report data is obtained from the daily report and monthly report storage module for visual presentation, so that a user can visually understand data information, and finally, original data is extracted from the persistence and archiving storage module through a specified time period and an equipment number to compare the original data with the report data to verify a result, so that the data accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of PLC data statistics, and in particular to a production data statistics method, system, electronic device and storage medium based on PLC. Background Art

[0002] In industrial production, PLC (Programmable Logic Controller) is a device widely used in production line control and data collection. PLC can collect the operating status and operation data of sensors, actuators and other equipment through communication ports (such as Ethernet, serial ports, etc.), such as the speed value of the speed sensor, the number of revolutions of the motor Hall sensor, the output value of the current transmitter, the temperature value of the temperature sensor, the distance value of the infrared ranging sensor, the status value of the actuator, etc.

[0003] The data acquisition module of the PLC needs to consider factors such as data reliability, accuracy, and real-time performance. Engineers can determine the acquisition method, sampling period, and data accuracy through understanding and experimentation of the equipment. The collected data can be uploaded to the cloud for analysis and processing through existing communication methods, such as Modbus and OPC UA protocols.

[0004] Currently, the production data content on most equipment is very single, and on-site production personnel can obtain little data. However, PLC collects data from a large number of different types of production equipment, which increases the production data. The space for persistent storage is limited, and the ever-increasing amount of data will inevitably lead to the problem of insufficient storage space. Summary of the invention

[0005] The technical problem to be solved by this application is that the production data content on most of the current equipment is too single, and the on-site production personnel can obtain little data. However, PLC collects data from a large number of different types of production equipment, which increases the production data. The space for persistent storage is limited, and the ever-increasing amount of data will inevitably lead to the problem of insufficient storage space.

[0006] In order to solve the above problems, in order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a production data statistics method, system, electronic device and storage medium based on PLC.

[0007] In a first aspect, the present invention discloses a production data statistics method based on PLC, which comprises the following steps:

[0008] Obtain the original equipment production data and the collection time collected by the PLC, store them in the cache module, and record the stored timestamp; the original equipment production data includes the equipment number and the signal value;

[0009] The original equipment production data temporarily stored in the cache module is divided into data of corresponding dates and months according to the data collection time, and the original equipment production data of the corresponding date is respectively filled into the daily report storage module and the monthly report storage module;

[0010] Setting a memory storage capacity threshold of the cache module, when the memory of the cache module reaches the preset threshold, writing the original data records in the cache module into the persistent storage module in batches; and recording the timestamp of the data stored in the persistent storage module;

[0011] Regularly scan the original data records and report data in the persistent storage module to determine whether the timestamp of the data stored in the persistent storage module exceeds the preset time threshold. If the timestamp exceeds the preset time threshold, delete the original data records and report data. If the timestamp does not exceed the preset time threshold, transfer the data to the archive storage module.

[0012] Obtain the query conditions input by the user, and according to the query conditions, use the preset data filtering and query rules to obtain the corresponding statistical report data from the daily storage module and the monthly storage module, visualize the obtained report data, and generate a statistical result interface containing tables and charts;

[0013] Get the specified time period and device number, input the persistent storage module and the archive storage module to extract the corresponding original device production data, compare it with the statistical report data, and verify the statistical results.

[0014] Preferably, the process of acquiring the original equipment production data and the acquisition time collected by the PLC, storing them in a cache module, and recording the stored timestamp specifically includes the following steps:

[0015] Obtain the equipment's operating status signals, including power-on, power-off, standby and alarm signals, and generate raw operating status data records with timestamps based on signal type and acquisition time;

[0016] Obtain the output pulse signal of the equipment, including the number of qualified products, defective products and scrapped products, and generate the original output data record with time stamp according to the signal type and acquisition time;

[0017] Extract the original equipment production data from the original data records of the operating status and the original data records of the output, including the equipment number, signal value and acquisition time, and build a unified original equipment production data record format;

[0018] The original equipment production data in a unified recording format is written into the cache module for storage, and the cache module memory buffer records the amount of data written and the storage timestamp.

[0019] Preferably, the setting of the cache module memory storage capacity threshold, when the memory of the cache module reaches the preset threshold, batch writing the original data records in the cache module to the persistent storage module specifically includes the following steps:

[0020] When the original device production data is stored in the cache module, the cache module records the data volume of the stored original device production data;

[0021] Preset a memory storage threshold, count the total amount of data stored in the cache module, and determine whether the total amount of data temporarily stored in the cache module exceeds the preset threshold;

[0022] If the preset threshold is reached, the original data records in the cache module are written to the persistent storage in batches. After the data is written, the corresponding original data in the cache module is deleted;

[0023] For the data in the daily report storage module and the monthly report storage module, the expired data shall be deleted regularly and the new data shall be updated.

[0024] Preferably, the periodic scanning of the original data records and report data in the persistent storage to determine whether they exceed a preset time threshold and deleting the original data records and report data that exceed the preset time threshold specifically includes the following steps:

[0025] Obtain the original data records and report data in the persistent storage, and for each piece of data, determine whether its creation time exceeds the preset timeliness threshold;

[0026] If the creation time of the data exceeds the threshold, the data record will be marked as deleted, but the actual deletion operation will not be performed for the time being. Instead, physical deletion will be performed in batches after a certain number of records have accumulated.

[0027] If the creation time of the data does not exceed the threshold, the data record is transferred to the archive storage, and an index is created for the data in the archive storage;

[0028] For data transferred to archive storage, inverted index technology is used to establish an index data structure based on the key fields of the data;

[0029] For data deletion operations, different trigger thresholds are set according to the amount of data. When the accumulated amount of data to be deleted reaches the threshold, the batch deletion operation is triggered;

[0030] When archiving and deleting data, the creation time of the data is judged to determine whether it is the last original data record of the day, month or year. If so, it is retained without archiving or deleting.

[0031] Regularly perform data integrity checks on data in archive storage and persistent storage. By comparing the existence of the last piece of data every day, month, and year, determine whether there is any data omission or loss. If a problem is found, repair the data.

[0032] Preferably, the method of obtaining the query conditions input by the user, obtaining the corresponding statistical report data from the daily storage module and the monthly storage module according to the query conditions, using preset data filtering and query rules, visually presenting the obtained report data, and generating a statistical result interface including tables and charts, specifically includes the following steps:

[0033] Get the query conditions entered by the user and use them as the basis for data filtering and query;

[0034] According to the preset data filtering and query rules, statistical report data matching the query conditions are obtained from the daily report storage module and the monthly report storage module, and the obtained statistical report data are preprocessed;

[0035] Using data visualization technology, the pre-processed statistical report data is converted into intuitive and easy-to-understand charts and tables to generate a statistical result interface;

[0036] In the statistical results interface, a data drill-down function is provided, allowing users to drill down to view more fine-grained data by clicking on a specific area in a chart or table.

[0037] Preferably, the obtaining of the specified time period and device number, inputting into the persistent storage module and the archiving storage module to extract the corresponding original device production data, comparing with the statistical report data, and verifying the statistical results specifically includes the following steps:

[0038] Get the time period and device number specified by the user, and query the corresponding raw data records from the persistent storage or archive storage based on these parameters;

[0039] Pre-process the acquired raw data records, including data cleaning and format conversion, so as to compare with the report data;

[0040] Obtain report data corresponding to the user-specified time period and device number from the report system;

[0041] Use similarity algorithm to compare the pre-processed raw data records with the report data and calculate the similarity score between the two;

[0042] Determine whether the similarity score exceeds a preset threshold. If so, the statistical result is considered accurate; otherwise, the statistical result is considered incorrect.

[0043] If the statistical results are wrong, the user will be prompted that the data verification has failed, and the difference between the original data record and the report data will be recorded for subsequent analysis and processing;

[0044] According to the verification results and difference information, the statistical algorithm of the reporting system is optimized and adjusted to improve the accuracy of the report data;

[0045] At the same time, the verification results are fed back to the user, and the option of regenerating the report is provided.

[0046] Preferably, the method further comprises the following steps:

[0047] Collect historical data displayed in the daily storage module and the monthly storage module, establish a prediction model, and predict the future output and possible failures of the equipment based on the equipment operation status signal and output pulse signal;

[0048] The decision support system based on artificial intelligence optimizes and analyzes historical data and provides production optimization suggestions for current equipment.

[0049] In a second aspect, the present invention discloses a PLC-based production data statistics system, which includes: steps including the above-mentioned PLC-based production data statistics method.

[0050] In a third aspect, the present invention discloses an electronic device, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0051] Memory, used to store computer programs;

[0052] The processor is used to implement the steps of the PLC-based production data statistics method when executing the program stored in the memory.

[0053] In a fourth aspect, the present invention discloses a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of a production data statistics method based on PLC.

[0054] The above technical solution provided by this application has the following advantages compared with the prior art:

[0055] The present application provides a PLC-based production data statistics method, system, electronic device and storage medium, wherein the method obtains the original equipment production data and collection time of the production equipment controlled by the PLC, stores them in a cache module and records a timestamp, and the cache module is divided into a daily storage module and a monthly storage module according to the collection time, so that the data is displayed according to date and month; by setting a cache memory threshold and a data age threshold, the storage space is cleaned up regularly to avoid excessive occupation of storage space by data, so that the persistent storage space maintains free space for saving data; according to user query conditions, report data is obtained from the daily and monthly storage modules for visual presentation, so that users can intuitively understand the data information, and finally, by specifying a time period and equipment number, the original data is extracted from the persistent and archive storage modules and the report data is compared and verified to improve data accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0058] Figure 1 A flowchart of a PLC-based production data statistics method provided in this application;

[0059] Figure 2 A module diagram of a PLC-based production data statistics system provided in this application;

[0060] Figure 3 A module diagram of a cache module of a PLC-based production data statistics system provided in this application.

[0061] 1. Production data statistics system based on PLC;

[0062] 11. Storage module; 12. Display module; 13. Delete module; 14. Statistics module;

[0063] 111. Cache module; 112. Daily report storage module; 113. Monthly report storage module; 114. Persistent storage module; 115. Archive storage module. DETAILED DESCRIPTION

[0064] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0065] First, see Figure 1 The present invention discloses a production data statistics method based on PLC, which comprises the following steps:

[0066] Step S1: obtaining the original equipment production data and the collection time collected by the PLC, storing them in the cache module, and recording the stored timestamp; the original equipment production data includes the equipment number and the signal value;

[0067] Step S2: dividing the original equipment production data temporarily stored in the cache module into data of corresponding dates and months according to the data collection time, and filling the original equipment production data of the corresponding dates into the daily report storage module and the monthly report storage module respectively;

[0068] Step S3: setting a memory storage capacity threshold of the cache module. When the memory of the cache module reaches the preset threshold, batch-writing the original data records in the cache module into the persistent storage module; and recording the timestamp stored in the persistent storage module;

[0069] Step S4: regularly scan the original data records and report data in the persistent storage module, determine whether the timestamp stored in the persistent storage module exceeds the preset time threshold, delete the original data records and report data that exceed the preset time threshold, and transfer the data to the archive storage module if it does not exceed the preset threshold;

[0070] Step S5: Periodically perform verification processing on the persistent storage module and the archive storage module. The specific steps are as follows: obtain a period of time and a specified device number, input them into the persistent storage module and the archive storage module to extract the corresponding original device production data, obtain the corresponding statistical report data from the daily storage module and the monthly storage module for the specified time period and the specified device number, compare the statistical report data with the extracted original device production data, obtain a verification result, and determine whether the extracted original device production data is consistent with the statistical report data;

[0071] Step S6: Obtain the query conditions input by the user, and based on the query conditions, use preset data filtering and query rules to obtain corresponding statistical report data from the daily storage module and the monthly storage module, visualize the obtained report data, and generate a statistical result interface containing tables and charts.

[0072] Specifically, step S1 obtains the operation status signal and output pulse signal of the relevant equipment of the production equipment controlled by the PLC, the operation status signal includes power on, power off, standby and alarm signals, the output pulse signal includes qualified product, defective product and scrap quantity signals, the equipment number, the signal value of the corresponding equipment, the signal value collection time, the equipment number and the signal value of the corresponding equipment are recorded as the original equipment production data, the original equipment production data and the collection time are recorded in the cache module, and at the same time, the time recorded in the cache module is recorded. In addition, a sensor for collecting data is set on the PLC, which is used to collect related data, including time records, data corresponding sensors, such as temperature, humidity, etc.

[0073] Specifically, in step S2, the original equipment production data temporarily stored in the cache module is divided into data of corresponding dates and months according to the data collection time, and then the original equipment production data of the corresponding dates are respectively filled into the daily storage module and the monthly storage module. The daily storage module and the monthly storage module correspond to the production report data. The data in the daily storage module and the monthly storage module are displayed to the outside through reports, and the report data is displayed through the display module for the convenience of workers to view. The daily storage module can update the new data and delete the old data after 24 hours, and the monthly storage module can update the new data and delete the old data after one month.

[0074] Specifically, in step S3, the memory of the cache module itself has certain limitations. If it exceeds the limit, the remaining amount of the cache module will be reduced. When encountering a large amount of data, it is easy to fail to write. It is necessary to set a storage threshold, and a certain amount of storage is left for subsequent large data to store data to avoid data being unable to be stored. When the threshold is exceeded, the data in the cache module is transferred to the persistent storage module, the data in the cache module is cleared, and new data is written. Alternatively, the old data is transferred to the persistent storage module, the old data is not directly cleared, and the new data directly overwrites the old data, reducing the number of operation steps.

[0075] Specifically, step S4, periodic scanning is performed in the persistent storage module, and the storage time of the data is calculated according to the time when the data is stored in the persistent storage module, and compared with the preset time threshold. When the preset time threshold is exceeded, it is judged as timed-out data and can be deleted. Data exceeding the preset threshold can be directly recorded in the archive storage module for archive processing, and temporarily retained in the persistent storage module. After the threshold is exceeded later, it can be deleted again, or after being recorded in the archive storage module, it can be deleted to increase the remaining memory space of the persistent storage module. Among them, the persistent storage module can be scanned regularly, and a period of time can be preset, such as a quarter, a year, etc., and data that is stored for a long time can be regularly processed. According to its storage time, it is judged as timed-out data and does not need to be stored anymore.

[0076] Specifically, step S5, by obtaining the original equipment production data stored in the persistent storage module and the archive storage module, and comparing it with the data stored in the cache module, the daily storage module, and the monthly storage module, verifies whether the data in the persistent storage module and the archive storage module are correct, thereby improving the accuracy and reliability of the data statistics results. Regularly and carefully verifying the data in the persistent storage module and the archive storage module can ensure the correctness of the internally stored data, which is convenient for subsequent statistical processing of previous data.

[0077] Specifically, step S6 obtains the query conditions input by the user, obtains the corresponding statistical report data from the daily storage module and the monthly storage module according to the preset data filtering and query rules, visualizes the obtained report data, and generates a statistical result interface including tables and charts. According to user needs, data can be flexibly obtained and visualized, and tables and charts can intuitively display data information, making it convenient for users to quickly understand the statistical results of the data.

[0078] Step S1 specifically includes the following steps:

[0079] Step S11: Acquire the operation status signal of the device, including power-on, power-off, standby and alarm signals, and generate the operation status raw data record with time stamp according to the signal type and acquisition time;

[0080] Step S12: Obtain the output pulse signal of the equipment, including the number signals of qualified products, defective products and waste products, and generate the output raw data record with time stamp according to the signal type and acquisition time;

[0081] Step S13: extracting original equipment production data from the operation status original data record and the output original data record, including equipment number, signal value and acquisition time, and constructing a unified original equipment production data record format;

[0082] Step S14: the original equipment production data in a unified recording format is written into the cache module for storage, and the cache module memory buffer records the amount of data written and the storage timestamp.

[0083] Specifically, by recording these operation status signals and their acquisition time, the operation mode of the equipment at different times can be accurately tracked. The use time and use cycle of the equipment can be judged by the startup time and shutdown time. The standby time helps to analyze the idleness of the equipment. The alarm signal combined with the timestamp can quickly locate the specific time when the equipment is abnormal, providing an important basis for equipment maintenance and management. By obtaining the qualified, defective and waste quantity signals of the equipment, the product output at different time points can be accurately counted. Among them, the number of qualified products can reflect the effective production capacity of the equipment. The number of defective and waste signals combined with the acquisition time can help analyze the time trend of quality problems in the production process, providing data support for quality control and production process improvement. The unified recording format facilitates the comprehensive management and analysis of different types of data (operation status data and output data). The equipment number can distinguish the data of different equipment. The signal value contains key information related to the equipment operation status or output. The acquisition time provides a basis for the time series analysis of the data, making the association and comparison between data more convenient. The construction of a unified original equipment production data recording format facilitates the comprehensive management, query and analysis of different types of data, and improves the efficiency of data processing. When data is stored in the cache module, a buffer needs to be reserved in the cache module in advance to record the amount of data written into the cache module and the recorded timestamp, and match them with the corresponding data to facilitate subsequent data processing. At the same time, it helps to sort the data according to the storage time or data amount.

[0084] It can be understood that a complete data processing process is constructed by collecting, recording, extracting and temporarily storing the equipment's operating status signals and output pulse signals. Data is obtained from all aspects of equipment operation, sorted and stored in a unified format, providing a comprehensive and organized data foundation for subsequent equipment management, production monitoring, quality control and data analysis.

[0085] Step S2 specifically includes the following steps:

[0086] Step S21: the original equipment production data is grouped according to the equipment number, and then all the original equipment production data is divided into corresponding dates and months according to the collection time;

[0087] Step S22: Classify the data divided by corresponding date and month into the daily report storage module and the monthly report storage module;

[0088] Step S23: Establishing time indexes for the equipment operation status table and the daily report storage module and the monthly report storage module.

[0089] Specifically, grouping by equipment number can bring together the data of the same equipment, making it easier to analyze the production of each equipment separately. Dividing the data into dates and months by the time of collection can help to make more detailed statistics and analysis of equipment production data from the time dimension. For example, for a certain equipment, you can view the fluctuations in production data every day and every month, which is convenient for discovering the production rules or abnormalities of the equipment in different time periods. The daily report storage module can provide detailed information on daily equipment production, which is convenient for daily production monitoring, quality inspection and other work. The monthly report storage module can show the monthly production trend of the equipment from a more macro perspective, such as the total monthly output, the monthly output comparison of different equipment, etc., to provide a basis for long-term production planning and resource allocation. By storing data in different modules by day and month, hierarchical management of data is achieved, making data of different time scales easy to find and analyze. Establishing a time index can quickly locate and associate data in different modules. For example, when you need to query the operating status of a certain equipment at a specific time and the production data of the day or month, you can quickly obtain relevant information through the time index to improve the efficiency of data query and analysis. The establishment of a time index greatly improves the speed of querying data between the equipment operation status table and the storage module, and can quickly obtain the required equipment production and operation information.

[0090] It can be understood that the original equipment production data is first grouped and divided by time, then classified into different storage modules, and finally a time index is established. Through this process, hierarchical management of equipment production data, classified storage of time dimensions, and fast association query between data are achieved.

[0091] Step S3 specifically includes the following steps:

[0092] Step S31: when the original device production data is stored in the cache module, the cache module records the data volume of the stored original device production data;

[0093] Step S32: Preset a memory storage threshold, count the total amount of data stored in the cache module, and determine whether the total amount of data temporarily stored in the cache module exceeds the preset threshold;

[0094] Step S33: if the preset threshold is reached, the original data records in the cache module are batch-written to the persistent storage, and after the data is written, the corresponding original data in the cache module is deleted;

[0095] Step S34: For the data in the daily report storage module and the monthly report storage module, regularly delete the expired data and update the new data.

[0096] Specifically, when the original device production data is stored in the cache module, the cache module records the amount of data stored, which helps to grasp the storage status of the data in the cache module in real time, provides basic data for subsequent judgment of whether the storage threshold is reached, and facilitates the management of the storage resources of the cache module. By setting the threshold and comparing it, it is possible to timely find out whether the cache module is about to or has reached the storage limit. This helps to avoid problems such as performance degradation or overflow of the cache module due to storing too much data, and ensures the normal operation of the cache module. Writing data in batches to persistent storage can release the space of the cache module in time so that the cache module can continue to receive new original device production data. At the same time, deleting the data written to persistent storage in the cache can avoid duplicate storage of data and improve the utilization of storage resources. Regularly deleting overdue data can release the storage space of the daily and monthly report storage modules and avoid storing too much useless data. Updating new data can ensure that the data in the storage module is always kept up to date, meet the timeliness requirements of the data, and facilitate subsequent query, analysis and other operations.

[0097] It can be understood that the cache module is responsible for temporarily storing and recording the amount of data, and when the threshold is reached, the data is written in batches to persistent storage; at the same time, the daily and monthly storage modules regularly clean up overdue data and update new data to ensure the validity of the data and the rational use of storage space. By recording the amount of data in the cache module and setting the threshold, the cache space can be managed in a timely and effective manner, avoiding problems such as cache overflow, and ensuring the efficient operation of the cache module. Writing cache data to persistent storage in a timely manner and deleting the corresponding data in the cache, as well as regularly cleaning up overdue data in the daily and monthly storage modules, can help optimize the use of storage resources and reduce the waste of storage space. The overdue data deletion and new data update operations of the daily and monthly storage modules ensure the timeliness of the stored data, so that the data can reflect the latest situation of equipment production and meet data usage requirements. Reasonable cache management and data maintenance of the storage module help improve the stability of the entire data storage system and reduce system failures caused by data storage problems.

[0098] Step S4 specifically includes the following steps:

[0099] Step S41: obtaining the original data records and report data in the persistent storage, and determining for each piece of data whether its creation time exceeds a preset timeliness threshold;

[0100] Step S42: if the creation time of the data exceeds the threshold, the data record is marked as deleted, but the actual deletion operation is not performed temporarily. Instead, physical deletion is performed in batches after a certain number of data are accumulated;

[0101] Step S43: if the creation time of the data does not exceed the threshold, the data record is transferred to the archive storage, and an index is created for the data in the archive storage;

[0102] Step S44: For the data transferred to the archive storage, an inverted index technology is used to establish an index data structure according to the key fields of the data;

[0103] Step S45: For the data deletion operation, different trigger thresholds are set according to the amount of data. When the accumulated amount of data to be deleted reaches the threshold, the batch deletion operation is triggered;

[0104] Step S46: When performing data archiving and deletion operations, determine whether the data is the last original data record of the day, month or year by judging the creation time of the data. If so, retain it without archiving or deleting it;

[0105] Step S47: Perform data integrity checks on the data in archive storage and persistent storage regularly. By comparing the existence of the last piece of data every day, month, and year, determine whether there is any data omission or loss. If a problem is found, perform data repair.

[0106] Specifically, the original data records and report data in the persistent storage are obtained, and the creation time of each data is checked to see if it exceeds the preset time threshold, which helps to determine whether the data is outdated, thereby providing a basis for subsequent data management operations (such as archiving or deletion). By setting the time threshold, data can be reasonably managed according to business needs and the timeliness of data value to avoid useless data occupying storage space for a long time. If the creation time of the data exceeds the threshold, the data record is marked as deleted, but the actual deletion operation is not performed immediately. Instead, it is physically deleted in batches after a certain number of data are accumulated. Marking the deleted state can logically isolate the data to be deleted to avoid misuse in subsequent operations. Batch physical deletion can reduce the impact of frequent deletion operations on the performance of the storage system and improve the efficiency of data management, especially when processing large amounts of data. If the creation time of the data does not exceed the threshold, the data record is transferred to the archive storage, and an index is established for the data in the archive storage. Archiving the non-outdated data helps to preserve valuable data for a long time, which is convenient for future query and audit. Establishing an index can improve the query speed of archived data, so that the required data records can be quickly located when the archived data needs to be accessed. For data transferred to archive storage, inverted index technology is used to establish an index data structure based on the key fields of the data. Inverted index technology can quickly locate relevant data records based on key fields, and is particularly suitable for quick query of specific information in archived data, which improves the retrieval efficiency of archived data. For example, it is very useful when searching for all data records related to specific keywords. For data deletion operations, different trigger thresholds are set according to the amount of data. When the accumulated amount of data to be deleted reaches the threshold, the batch deletion operation is triggered. In this way, the frequency and scale of deletion operations can be flexibly controlled according to the performance of the storage system and the actual amount of data. Different amounts of data may have different effects on the storage system. Setting a suitable trigger threshold can avoid system performance problems caused by deleting too much data at one time, or increase system overhead due to frequent data deletion. When performing data archiving and deletion operations, the creation time of the data is judged to determine whether it is the last original data record of the day, month or year. If so, it is retained without archiving or deleting. The last piece of data has special statistical or summary significance. Retaining this data can ensure the integrity of the data and facilitate daily, monthly or annual data statistics, report generation, and data analysis. Data integrity checks are performed regularly on data in archive storage and persistent storage. By comparing the existence of the last piece of data every day, month, and year, it is determined whether there is any data omission or loss. If a problem is found, the data is repaired. Data integrity checks can ensure the accuracy and integrity of data and promptly detect problems that may occur during data storage, such as data loss or damage.By fixing the discovered problems, the reliability of the data can be ensured, providing accurate data support for business decisions and data analysis.

[0107] It can be understood that the use of batch deletion and setting trigger thresholds based on data volume reduces the impact of frequent deletion operations on the storage system and optimizes system performance. Archiving or deleting operations based on the timeliness of data can make rational use of storage space while retaining valuable data, in line with the principle of data lifecycle management. Establishing indexes and using inverted index technology in archive storage improves the query speed of archived data and facilitates data retrieval and use. Special case handling mechanisms and regular data integrity checks ensure data integrity, avoid data loss or damage caused by misoperation or system failure, and provide guarantees for data reliability.

[0108] Step S5 specifically includes the following steps:

[0109] Step S51: Obtain the time period and device number, and regularly perform verification processing on the persistent storage module and the archive storage module;

[0110] Step S52: querying the corresponding original data record from the persistent storage or archive storage according to the specified time period and device number;

[0111] Step S53: Obtaining report data corresponding to the specified time period and device number from the report system;

[0112] Step S54: using a similarity algorithm to compare the pre-processed original data record with the report data, and calculating a similarity score between the two;

[0113] Step S55: determining whether the similarity score exceeds a preset threshold value, if so, the original data record is considered accurate, otherwise, the original data record is considered incorrect;

[0114] Step S56: If the original data record is incorrect, the user is prompted that the data verification has failed, and the difference information between the original data record and the report data is recorded for subsequent analysis and processing;

[0115] Step S57: According to the verification result and the difference information, the timestamp corresponding to the data in the report data is indexed into the original device production data in the cache module, and the original device production data is cached in the persistent storage module and the archive storage module.

[0116] Specifically, a specific time period is determined according to a certain cycle and a specific device number is specified, which provides an accurate range limitation for subsequent data query and analysis. According to the time period and device number specified by the user, the corresponding original data record is searched from the persistent storage or archive storage. These original data records are the most authentic and original operation information records of the equipment in a specific time period, and are the basis for data verification. Obtaining these data by querying can provide a comprehensive and accurate original basis for subsequent comparison with report data. Obtain report data matching the user-specified time period and device number from the report system. Report data is the data result presented after specific statistics and processing. The data is obtained to compare with the original data record, so as to verify the accuracy of the report data and check whether there is any deviation in the data processing process. The original data record and the report data are compared by a similarity algorithm to obtain the similarity score between the two. The similarity score is a quantitative indicator that can intuitively reflect the similarity between the original data record and the report data. This score is an important basis for judging the accuracy of the report data and the original production data, and helps to evaluate the matching between the two in an objective way. Compare the similarity score with the preset threshold. If the similarity score exceeds the threshold, the original data record is determined to be accurate; otherwise, the original data record is determined to be incorrect. When the original data record is incorrect, the user is prompted that the data verification has failed, and the difference information between the original data record and the report data is recorded for subsequent analysis and processing. According to the verification results and difference information, the original device production data in the cache module is indexed using the timestamp corresponding to the data in the report data, and the original device production data is cached to the persistent storage module and the archive storage module. When the statistical results are incorrect, the user can be prompted in time and the difference information is recorded in detail, which helps to quickly locate the problem and provides strong support for subsequent error correction and report system optimization. Reasonable cache storage of the original device production data based on the verification results ensures the long-term preservation and traceability of the data, which is conducive to further analysis and utilization of the data.

[0117] It can be understood that based on the time period and device number specified by the user, the original data records and report data are obtained from the persistent storage or archive storage and the report system, the accuracy of the report data is verified by calculating the similarity score, and the accuracy of the statistical results is determined based on the verification results. If the original data record is incorrect, the corresponding processing is performed and the difference information is recorded. Finally, the original device production data is cached and stored based on the verification results and the difference information.

[0118] Step S6 specifically includes the following steps:

[0119] Step S61: obtaining the query conditions input by the user and using them as the basis for data filtering and querying;

[0120] Step S62: According to the preset data filtering and query rules, statistical report data matching the query conditions are obtained from the daily report storage module and the monthly report storage module, and the obtained statistical report data are pre-processed;

[0121] Step S63: using data visualization technology to convert the pre-processed statistical report data into intuitive and easy-to-understand charts and tables to generate a statistical result interface;

[0122] Step S64: In the statistical result interface, a data drill-down function is provided, allowing the user to view more fine-grained data by clicking on a specific area in a chart or table.

[0123] Specifically, according to the preset data filtering and query rules, the statistical report data required by the user can be accurately located through the set data filtering and query rules, avoiding the acquisition of a large amount of irrelevant data, and improving the efficiency and accuracy of data acquisition. Statistical report data that meets the query conditions are extracted from the daily storage module and the monthly storage module, and then the acquired data is preprocessed. The preprocessed data can clean and convert the original data, such as processing missing values, unifying data formats, etc., to ensure the quality of the data and prepare for subsequent data visualization. Data visualization presents data in an intuitive and easy-to-understand way, allowing users to quickly understand the main characteristics and trends of the data, and convert the preprocessed statistical report data into intuitive charts (such as bar charts, line charts, etc.) and tables. For example, bar charts can be used to compare the size of different categories of data, line charts are suitable for showing the trend of data changes over time, and tables can present detailed data values, greatly improving the readability of the data. The statistical result interface displays the data in a visual form, which is convenient for users to view and analyze the data as a whole, providing an intuitive basis for decision-making. The data drill-down function meets the user's needs for deep data mining. After viewing the data at a macro level, users may want to delve deeper into the details behind certain data points. This feature allows users to gradually drill down from overall data to more specific and detailed data, providing multi-level data exploration capabilities to help discover potential relationships and problems in the data.

[0124] It can be understood that obtaining data through preset rules can accurately locate the required data, avoid data redundancy, and improve acquisition efficiency. Preprocessing the data ensures the quality of the data and lays a good foundation for subsequent analysis and presentation. Data visualization converts complex data into intuitive charts and tables, improves the readability and comprehensibility of the data, and facilitates users to quickly grasp the key information of the data. The data drill-down function provides users with multi-level data exploration capabilities, making data analysis more in-depth and comprehensive, and helping users discover more information hidden in the data.

[0125] After step S6, the following steps are also included:

[0126] Collect historical data displayed in the daily storage module and the monthly storage module, establish a prediction model, and predict the future output and possible failures of the equipment based on the equipment operation status signal and output pulse signal;

[0127] The decision support system based on artificial intelligence optimizes and analyzes historical data and provides production optimization suggestions for current equipment.

[0128] Specifically, historical data is collected comprehensively from the daily storage module and the monthly storage module. These data include detailed information such as the operation status signals (such as power-on, power-off, standby and alarm signals) of the equipment in different time periods (days and months) in the past, as well as the output pulse signals (the number of qualified products, defective products and waste products). Historical data is collected comprehensively from the daily storage module and the monthly storage module. These data include detailed information such as the operation status signals (such as power-on, power-off, standby and alarm signals) of the equipment in different time periods (days and months) in the past, as well as the output pulse signals (the number of qualified products, defective products and waste products). In the process of collecting data, it is necessary to ensure the accuracy and completeness of the data, clean the data, and remove data records with duplication, errors or serious omissions. In the process of data cleaning, a data filtering algorithm can be used, for example, to screen and remove output data that is obviously beyond the normal range or signal data that does not conform to the operation logic of the equipment. Data integration technology can be used to integrate data from different storage modules (daily and monthly reports) and deal with possible format differences and other issues. Accurate and complete data is the basis for establishing an effective prediction model. By cleaning and integrating data, data quality can be improved and prediction deviations caused by erroneous data can be reduced. Comprehensive data collection can cover all aspects of equipment operation and production, providing a rich source of information for accurately predicting future equipment output and failures.

[0129] According to the historical data in the daily storage module and the monthly storage module, the daily and monthly production forecasting models of the equipment are constructed. According to the collected equipment operation status signals and output pulse signal data, the appropriate forecasting model is selected, such as the time series analysis model (such as the ARIMA model) or the machine learning model (such as the decision tree, neural network, etc.). Different forecasting models are suitable for different data characteristics and forecasting targets. Selecting the appropriate model can improve the accuracy and reliability of the forecast. The future output of the equipment and the possible failures can be predicted through the equipment operation status signals and output pulse signals in the current original equipment production data, so that the operator can handle them in advance and adjust the output value of the equipment.

[0130] Input the current equipment's operating status signal and output pulse signal into the established and optimized prediction model. For output prediction, the model predicts the output in the future (such as the next few days or weeks) based on the output trend in historical data and the current equipment's operating status, including the number of qualified products, defective products, and scrapped products. For fault prediction, the model predicts the time point and type of possible equipment failure based on the historical pattern of the equipment's operating status signal and the current status (for example, predicting that a certain component of the equipment may fail based on the frequency of the alarm signal and the equipment's operating time). Being able to understand the equipment's future output in advance helps with production planning, such as raw material procurement and personnel scheduling. In addition, fault prediction can enable equipment maintenance and upkeep in advance, reduce equipment downtime, improve production efficiency, and reduce maintenance costs.

[0131] Use artificial intelligence decision support system to conduct in-depth analysis of the collected historical data. This system can use rule-based reasoning, machine learning algorithms (such as cluster analysis, association rule mining, etc.) and other technologies. Providing targeted production optimization suggestions can improve the production efficiency of equipment, reduce the defective product rate, and improve the economic benefits of the enterprise.

[0132] As an embodiment, rule-based reasoning is used to perform optimization analysis. According to the expert knowledge and experience in the field of equipment production, a rule base is established, and historical data is matched with the rule base to find data patterns that meet the rules. Rule-based reasoning can combine expert knowledge to quickly screen out valuable data patterns and provide a direct basis for production optimization. If rule-based reasoning concludes that equipment maintenance within a specific time period can improve overall production efficiency, then it is recommended to arrange an equipment maintenance plan within the specific time period.

[0133] As an embodiment, a cluster analysis algorithm is used to optimize the analysis of a large amount of data, cluster the different operating states and output data of the equipment, find similar operating state and output combinations, and discover potential production rules. For example, using the K-means clustering algorithm, data points are divided into different clusters according to the characteristics of the data. Cluster analysis helps to discover hidden patterns in equipment operation and production, which may be difficult to discover with traditional analysis methods. If cluster analysis finds that the output is low under certain operating conditions, it can be recommended to adjust the operating parameters or operating procedures of the equipment to avoid entering these states as much as possible.

[0134] As an embodiment, an optimization analysis is performed through an association rule mining algorithm to find the correlation between the equipment operation status signal and the output pulse signal, such as the change pattern of the output under normal or overloaded operation conditions. Association rule mining can use the Apriori algorithm to mine frequent item sets and association rules. Association rule mining can reveal the intrinsic connection between equipment operation and output, and provide a comprehensive perspective for optimizing production. When association rule mining shows that a certain operation state is related to an increase in the output of defective products, measures to improve the operation state are proposed, such as maintaining the equipment or adjusting the control parameters of the equipment.

[0135] After step S6, the following steps are also included:

[0136] Regularly monitor the data quality of raw data records. Evaluate data quality by checking data completeness (such as whether there are missing fields), accuracy (such as whether the signal value is within a reasonable range), and consistency (such as whether the same data from different data sources is consistent).

[0137] If data quality problems are found, a data repair mechanism is used. For example, for missing acquisition time fields, interpolation repair can be performed based on the acquisition time of the previous and next data; for inaccurate signal values, corrections can be made based on the historical normal data of the device.

[0138] Specifically, the data in each storage module may be distorted or lost due to multiple data processing. Therefore, the data in each storage module needs to be monitored regularly. When problems occur, they need to be repaired to ensure data accuracy.

[0139] Second, see Figure 2-3 The present invention discloses a PLC-based production data statistics system 1, which includes the steps of the above-mentioned PLC-based production data statistics method.

[0140] The system includes a storage module 11, a display module 12, a deletion module 13, and a statistics module 14; the storage module 11 includes a daily storage module 112, a monthly storage module 113, a cache module 111, a persistent storage module 114, and an archive storage module 115. The display module 12 is connected to the daily storage module 112 and the monthly storage module 113. The deletion module 13 is connected to the storage module 11. The statistics module 14 is connected to the storage module 11. The deletion module 13 deletes the data in the storage module 11 according to preset rules. The display module 12 displays the data inside the daily storage module 112 and the monthly storage module 113. The statistics module 14 collects relevant data of the production equipment controlled by the PLC and transmits it to the storage module 11.

[0141] Each module of the system is implemented according to the steps in the PLC-based production data statistics method. Specifically, the original equipment production data and the collection time of the production equipment controlled by the PLC are obtained, stored in the cache module 111 and the timestamp is recorded. The cache module 111 is divided into the daily storage module 112 and the monthly storage module 113 according to the collection time, so that the data is displayed according to the date and month; by setting the cache memory threshold and the data age threshold, the storage space is cleaned up regularly to avoid excessive occupation of the storage space by data, so that the persistent storage space maintains free space for saving data; according to the user's query conditions, the report data is obtained from the daily and monthly storage modules 113 for visual presentation, so that the user can intuitively understand the data information; finally, the original data is extracted from the persistent and archive storage module 115 by specifying the time period and equipment number, and the verification result is compared with the report data to improve the data accuracy.

[0142] In a third aspect, the present invention discloses an electronic device, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0143] Memory, used to store computer programs;

[0144] The processor is used to implement the steps of the PLC-based production data statistics method when executing the program stored in the memory.

[0145] The processor is implemented according to the steps in the PLC-based production data statistics method. Specifically, the original equipment production data and the collection time of the production equipment controlled by the PLC are obtained, stored in the cache module and the timestamp is recorded, and the cache module is divided into the daily storage module and the monthly storage module according to the collection time, so that the data is displayed according to the date and month; by setting the cache memory threshold and the data age threshold, the storage space is cleaned up regularly to avoid excessive occupation of the storage space by data, so that the persistent storage space maintains free space for saving data; according to the user query conditions, the report data is obtained from the daily and monthly storage modules for visual presentation, so that the user can intuitively understand the data information; finally, the original data is extracted from the persistent and archive storage modules by specifying the time period and equipment number, and the verification result is compared with the report data to improve the data accuracy.

[0146] In a fourth aspect, the present invention discloses a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of a production data statistics method based on PLC.

[0147] Specifically, the program stored in the storage medium is implemented according to the steps of the PLC-based production data statistics method.

[0148] Specifically, the original equipment production data and collection time of the production equipment controlled by the PLC are obtained, stored in the cache module and the timestamp is recorded. The cache module is divided into the daily storage module and the monthly storage module according to the collection time, so that the data is displayed by date and month; by setting the cache memory threshold and the data age threshold, the storage space is cleaned up regularly to avoid excessive occupation of storage space by data, so that the persistent storage space can keep free space for saving data; according to the user's query conditions, the report data is obtained from the daily and monthly storage modules for visual presentation, so that the user can intuitively understand the data information; finally, the original data is extracted from the persistent and archive storage modules by specifying the time period and equipment number, and the verification results are compared with the report data to improve data accuracy.

[0149] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0150] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.

[0151] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0152] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be connected, detachably connected, or integrated; it can be mechanically connected or electrically connected; it can be directly connected or indirectly connected through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0153] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may include that the first and second features are in direct contact, or may include that the first and second features are not in direct contact but are in contact through another feature between them. Moreover, a first feature being "above", "above" and "above" a second feature includes that the first feature is directly above and obliquely above the second feature, or simply indicates that the first feature is higher in level than the second feature. A first feature being "below", "below" and "below" a second feature includes that the first feature is directly below and obliquely below the second feature, or simply indicates that the first feature is lower in level than the second feature.

[0154] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms should not be understood as necessarily referring to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification.

[0155] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

[0156] The above is a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A production data statistics method based on PLC, characterized in that: The following steps are involved: Obtaining the original equipment production data and the collection time collected by the PLC, storing them in the cache module, and recording the stored timestamp; the original equipment production data includes the equipment number and the signal value; The original equipment production data temporarily stored in the cache module is divided into data of corresponding dates and months according to the data collection time, and the original equipment production data of the corresponding date is respectively filled into the daily report storage module and the monthly report storage module; Setting a memory storage capacity threshold of the cache module, when the memory of the cache module reaches the preset threshold, writing the original data records in the cache module into the persistent storage module in batches; The timestamp of recording the data in the persistent storage module; Regularly scan the original data records and report data in the persistent storage module to determine whether the timestamp of the data stored in the persistent storage module exceeds the preset time threshold. If the timestamp exceeds the preset time threshold, delete the original data records and report data. If the timestamp does not exceed the preset time threshold, transfer the data to the archive storage module. The persistent storage module and the archive storage module are periodically verified. The specific steps are as follows: obtain a period of time and a specified device number, input them into the persistent storage module and the archive storage module to extract the corresponding original device production data, obtain the corresponding statistical report data from the daily storage module and the monthly storage module for the specified time period and the specified device number, compare the statistical report data with the extracted original device production data, obtain the verification result, and judge whether the extracted original device production data is consistent with the statistical report data; Obtain the query conditions input by the user, and based on the query conditions, use preset data filtering and query rules to obtain corresponding statistical report data from the daily storage module and the monthly storage module, visualize the obtained report data, and generate a statistical result interface containing tables and charts.

2. The PLC-based production data statistics method according to claim 1, characterized in that: The method of obtaining the original equipment production data and the acquisition time collected by the PLC, storing them in the cache module, and recording the stored timestamp specifically includes the following steps: Obtain the equipment's operating status signals, including power-on, power-off, standby and alarm signals, and generate raw operating status data records with timestamps based on signal type and acquisition time; Obtain the output pulse signal of the equipment, including the number of qualified products, defective products and scrapped products, and generate the original output data record with time stamp according to the signal type and acquisition time; Extract the original equipment production data from the original data records of the operating status and the original data records of the output, including the equipment number, signal value and acquisition time, and build a unified original equipment production data record format; The original equipment production data in a unified recording format is written into the cache module for storage, and the cache module memory buffer records the amount of data written and the storage timestamp.

3. The PLC-based production data statistics method according to claim 1, characterized in that: The setting of the cache module memory storage capacity threshold, when the memory of the cache module reaches the preset threshold, batch writing the original data records in the cache module to the persistent storage module, specifically includes the following steps: When the original device production data is stored in the cache module, the cache module records the data volume of the stored original device production data; Preset a memory storage threshold, count the total amount of data stored in the cache module, and determine whether the total amount of data temporarily stored in the cache module exceeds the preset threshold; If the preset threshold is reached, the original data records in the cache module are written to the persistent storage in batches. After the data is written, the corresponding original data in the cache module is deleted; For the data in the daily report storage module and the monthly report storage module, the expired data shall be deleted regularly and the new data shall be updated.

4. The PLC-based production data statistics method according to claim 1, characterized in that: The method of periodically scanning the original data records and report data in the persistent storage to determine whether they exceed a preset time-limit threshold, and deleting the original data records and report data that exceed the preset time-limit threshold, specifically includes the following steps: Obtain the original data records and report data in the persistent storage, and for each piece of data, determine whether its creation time exceeds the preset timeliness threshold; If the creation time of the data exceeds the threshold, the data record will be marked as deleted, but the actual deletion operation will not be performed for the time being. Instead, physical deletion will be performed in batches after a certain number of records have accumulated. If the creation time of the data does not exceed the threshold, the data record is transferred to the archive storage, and an index is created for the data in the archive storage; For data transferred to archive storage, inverted index technology is used to establish an index data structure based on the key fields of the data; For data deletion operations, different trigger thresholds are set according to the amount of data. When the accumulated amount of data to be deleted reaches the threshold, the batch deletion operation is triggered; When archiving and deleting data, the creation time of the data is judged to determine whether it is the last original data record of the day, month or year. If so, it is retained without archiving or deleting. Regularly perform data integrity checks on data in archive storage and persistent storage. By comparing the existence of the last piece of data every day, month, and year, determine whether there is any data omission or loss. If a problem is found, repair the data.

5. The PLC-based production data statistics method according to claim 1, characterized in that: The step of obtaining the specified time period and device number, inputting the data into the persistent storage module and the archive storage module to extract the corresponding original device production data, comparing the data with the statistical report data, and verifying the statistical results specifically includes the following steps: Obtain the time period and device number, and regularly verify the persistent storage module and the archive storage module; Query the corresponding original data records from persistent storage or archive storage according to the specified time period and device number; Obtain report data corresponding to the specified time period and device number from the report system; Use similarity algorithm to compare the pre-processed raw data records with the report data and calculate the similarity score between the two; Determine whether the similarity score exceeds a preset threshold. If so, the original data record is considered accurate; otherwise, the original data record is considered incorrect. If the statistical results are wrong, the user will be prompted that the data verification has failed, and the difference between the original data record and the report data will be recorded for subsequent analysis and processing; According to the verification result and the difference information, the original device production data in the cache module is indexed with the timestamp corresponding to the data in the report data, and the original device production data is cached in the persistent storage module and the archive storage module.

6. The PLC-based production data statistics method according to claim 1, characterized in that: The method of obtaining the query conditions input by the user, and according to the query conditions, using the preset data filtering and query rules, obtaining the corresponding statistical report data from the daily storage module and the monthly storage module, visually presenting the obtained report data, and generating a statistical result interface including tables and charts, specifically includes the following steps: Get the query conditions entered by the user and use them as the basis for data filtering and query; According to the preset data filtering and query rules, statistical report data matching the query conditions are obtained from the daily report storage module and the monthly report storage module, and the obtained statistical report data are preprocessed; Using data visualization technology, the pre-processed statistical report data is converted into intuitive and easy-to-understand charts and tables to generate a statistical result interface; In the statistical results interface, a data drill-down function is provided, allowing users to drill down to view more fine-grained data by clicking on a specific area in a chart or table.

7. The PLC-based production data statistics method according to claim 1, characterized in that: The following steps are also included: Collect historical data displayed in the daily storage module and the monthly storage module, establish a prediction model, and predict the future output and possible failures of the equipment based on the equipment operation status signal and output pulse signal; The decision support system based on artificial intelligence optimizes and analyzes historical data and provides production optimization suggestions for current equipment.

8. A PLC-based production data statistics system, characterized in that: include: The method comprises the steps of the PLC-based production data statistics method as described in any one of claims 1 to 7.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor is used to implement the steps of the PLC-based production data statistics method described in any one of claims 1 to 7 when executing the program stored in the memory.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the PLC-based production data statistics method as described in any one of claims 1 to 7 are implemented.