Traditional Chinese medicine dispensing granule traceability system based on internet of things technology
By utilizing IoT technology, the Fellegi-Sunter model, and the Hirschberg global sequence alignment method, the accuracy problem of cross-system data association in the traceability system of traditional Chinese medicine formula granules was solved, enabling reliable reconstruction of traceability links and improving data accuracy and computational efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG JIATAI CHINESE MEDICINE PIECES CO LTD
- Filing Date
- 2026-03-01
- Publication Date
- 2026-06-09
Smart Images

Figure CN122175597A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information management and Internet of Things (IoT) application technology for traditional Chinese medicine, and in particular to a traceability system for traditional Chinese medicine formula granules based on IoT technology. Background Technology
[0002] With the widespread use of traditional Chinese medicine (TCM) formula granules in medical institutions, tracing the entire process of raw material sourcing, production and processing, quality testing, distribution, and clinical use has become an important technical direction for ensuring medication safety and meeting regulatory requirements. Existing TCM formula granule traceability systems typically rely on IoT devices and business systems to record relevant operational information at each business stage and realize data storage and retrieval through information systems.
[0003] In existing technologies, traceability data generated by different stages and systems differ in time base, identification rules, and process structure. Traceability processes often rely on batch numbers or manual rules for simple associations, making it difficult to accurately handle the common origin relationships between event records across systems. On one hand, existing traceability systems generally lack a quantitative mechanism for determining the common origin of event records. When data is missing, time discrepancies exist, or duplicate records are easily generated, leading to erroneous associations or broken links, affecting the reliability of traceability results. On the other hand, existing technologies typically do not incorporate business process consistency into the traceability link construction process, failing to effectively identify abnormal links inconsistent with the established production flow process. This makes it difficult to verify traceability results and simultaneously meet the requirements of accuracy and verifiability.
[0004] Therefore, how to provide a traceability system for traditional Chinese medicine formula granules based on Internet of Things technology is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] This invention proposes a traceability system for traditional Chinese medicine formula granules based on Internet of Things (IoT) technology. By collecting and standardizing multi-source event data generated throughout the entire process of raw materials, production, testing, circulation and use of traditional Chinese medicine formula granules, reliable correlation of cross-system events is achieved by using the probability calculation of the same source of records and process consistency constraints, and verifiable traceability links are reconstructed to realize continuous traceability of traditional Chinese medicine formula granules throughout the entire process.
[0006] A traceability system for traditional Chinese medicine formula granules based on Internet of Things (IoT) technology according to an embodiment of the present invention includes the following steps: The IoT event acquisition module acquires traceability event data from the raw materials, production, testing, circulation and use of traditional Chinese medicine formula granules, and generates event data streams. The event normalization and sequence construction module performs time calibration and identifier parsing on the event data stream, and generates a standardized set of traceable event sequences with batch identifiers as constraints. The probability homology calculation module constructs candidate record pairs for cross-system event records in the standardized traceable event sequence set, and calculates the homology probability of records based on the Fellegi-Sunter model to form an association probability matrix; The probability-constrained candidate chain generation module uses the correlation probability matrix as a constraint to perform soft aggregation on the standardized traceability event sequence set, generating a candidate traceability sequence set. The probability-weighted consistency alignment module performs Hirschberg global sequence alignment between the candidate traceability sequence set and the preset process baseline sequence, and maps the probability of record homology to alignment cost and path feasibility constraints. The link confirmation and output module reconstructs the traceability chain based on the alignment results and outputs verifiable traceability results when the recorded homology probability and alignment consistency meet preset conditions.
[0007] Optionally, generating an event data stream includes: When raw materials are received, processed, inspected, transferred, or used, business data is obtained through the corresponding data collection terminals or business system interfaces. Read the time of the business occurrence from the business data, convert it into an event time according to a unified time format, and write the event time into the time field of the event record; Read the subject code corresponding to the current business operation from the business object record, and write the subject code into the subject identifier field of the event record. The subject code is taken from the subject information registered in the collection terminal or business system. Read the object code of the operated object from the business object record and write the object code into the object identifier field of the event record. The object code corresponds to the variety code, packaging unit code or distribution carrier code of the Chinese herbal medicine formula granules. Read the batch code associated with the current business operation from the business object record and write the batch code into the batch identifier field of the event record. The batch code is taken from one of the raw material batch number, production batch number, test batch number, circulation batch number or usage batch number. The event type is determined based on the business operation type, and the event type is written into the event type field of the event record; The event record is formed by combining the event time, subject identifier, object identifier, batch identifier and event type, and the event records are output continuously in chronological order of the event time to generate an event data stream.
[0008] Optionally, generating a standardized set of traceable event sequences includes: The event data stream is taken as input, and the event records in the event data stream are read one by one. Perform time calibration on the event times in the event log, convert the event times to calibrated event times under the system time base, and replace the event time field in the event log with the calibrated event times; The subject identifier, object identifier, and batch identifier in the event record are parsed. The parsing process is limited to format standardization and legality verification of the identifier field. The parsed identifier results continue to be used as the subject identifier, object identifier, and batch identifier in the event record. The event records in the event data stream are grouped using the batch identifier in the event record as the grouping condition, and event records with the same batch identifier are grouped into the same event group; Within each event group, the event records are sorted according to the calibrated event time to generate an ordered list of event records with the corresponding batch identifier; The sorted list of event records within each event group is defined as a traceable event sequence, and the event records in the traceable event sequence are sequentially written with sequence position numbers. All traceable event sequences are aggregated to form a standardized traceable event sequence set, which is output with the batch identifier as the index.
[0009] Optionally, forming the correlation probability matrix includes: Read the event records in the tracing event sequence one by one; Within the range of event records with the same batch identifier, the event records are distinguished according to the record source system identifier. Candidate record pairs are constructed only between event records with different record source system identifiers, and each candidate record pair consists of two event records. For each candidate record pair, read the subject identifier, object identifier, event type and event time fields from the two event records, and generate a matching feature vector based on the field value relationship. The matching feature vector is composed of the field equality relationship and the event time difference. The candidate record pair set is used as input to the Fellegi–Sunter model. Matching probabilities are calculated based on both homology and non-homology hypotheses for the matching feature vectors. Finally, the homology probability of the candidate record pairs is calculated based on these matching probabilities. ; Using candidate record pairs as indices, the homology probability corresponding to each candidate record pair is written into the association probability matrix, and the matrix elements of the association probability matrix correspond one-to-one with the candidate record pairs.
[0010] Optionally, the Fellegi–Sunter model includes: Receive the generated set of candidate record pairs as input, and for each candidate record pair, read the subject identifier, object identifier, batch identifier, event type, event time, and record source system identifier of the first event record and the second event record; For each candidate record, a comparison status code is generated for each field. The comparison status code values are limited to A, D, and M. The subject identifier comparison status code is written as A when the subject identifiers of the two records are the same, D when the subject identifiers of the two records are different and both are not empty, and M when the subject identifier of at least one record is empty. The comparison status codes of object identifier, batch identifier, and event type are written according to the same rule. For each candidate record, compare the generated event time with the status code and calculate the event time difference between the two records. In both recorded events, the time is not empty and Write A when both record times are not empty and Write to D when the time is empty, and write to M when at least one record's event time is empty, time window. Taken from system configuration values; Write the comparison status code of subject identifier, object identifier, batch identifier, event type, and event time into the matching pattern vector in a fixed field order. and will Bind and store the corresponding candidate record pairs; During the model parameter construction phase, the following steps are performed: Generate sets of homologous and non-homologous samples based on deterministic anchor pairs, and calculate parameters accordingly. Filter the set of homologous anchor pairs within the candidate record pair set. The filtering criteria are limited to records whose source system identifiers are different, and whose object identifier comparison status code is A, event type comparison status code is A, event time comparison status code is A, and batch identifier comparison status code is A. Candidate records meeting these criteria are then written to... ; Filter the set of non-homologous anchor pairs within the candidate record pair set. The filtering criteria are limited to records whose source system identifiers are different, object identifier comparison status code is D, event type comparison status code is D, and batch identifier comparison status code is D. Candidate records meeting these criteria are then written to... ; right The comparison status codes of each field are counted separately to form a common-origin count table. ,in For field serial number and To compare status codes, and for Forming a non-homologous counting table ; Convert the homology count table into a homology matching probability table. The conversion method is limited to the serial number of each field. Calculate separately The non-same-origin count table is then converted into a non-same-origin matching probability table. The conversion method is limited to the serial number of each field. Calculate separately ; exist or When there is a zero count, the corresponding count value is written as 1, and the total count of the field sequence number is increased by 3 before the probability table calculation is performed. Calculate the prior homology probability The prior homology probability is written as and will and Both are written into the model parameter set; During the probability calculation phase: Before calculating the same-origin probability, candidate records are pruned for consistency with the execution process, and process consistency is written as an additional comparison field into the matching pattern vector. Read the system's configured process baseline sequence and establish a mapping table from event types to process position numbers. Write the position number corresponding to the event type of the first event record into the table. Write the position number corresponding to the event type of the second event record as... ; Calculate for each candidate record pair ,exist and Neither empty nor empty Write the process consistency comparison status code as A at that time. and Neither empty nor empty Write D when the position number cannot be obtained for at least one record, and write M when the position number cannot be obtained for the process consistency comparison status code, and append the process consistency comparison status code to the matching pattern vector. The end forms an extended matching pattern vector; For each candidate record pair, a pruning and writing rule is executed. When the object identifier comparison status code is A and the batch identifier comparison status code is D, the homology probability of the candidate record pair is directly written to 0 and marked as calculated. When the event type comparison status code is D and the process consistency comparison status code is A, the homology probability of the candidate record pair is directly written to 0 and marked as calculated. For candidate record pairs not marked as having been computed, perform homology probability calculation, specifically including: Read the comparison status code field by field based on the extended matching pattern vector, and read the corresponding value from the model parameter set. And calculate the log-likelihood ratio weights. : ; in, For field serial number The corresponding comparison status code; Based on weight Homology with prior Calculate the probability of homology and will Write the probability output item that corresponds one-to-one with the candidate record pair.
[0011] Optionally, methods for generating a set of candidate traceability sequences include: It receives a standardized set of traceable event sequences as the first input, an association probability matrix as the second input, and reads the event time, event type, and record source system identifier of the event records within the same batch identifier range; Within the same batch of event record sets, only among event records whose event times satisfy the chronological order constraint and whose record source system identifiers are different, the corresponding homologous probabilities are read based on the association probability matrix to construct directed candidate connections. For each directed candidate connection, it is retained only if its homology probability is not less than the first threshold. The event record with the earlier event time is written into the connection start point and the event record with the later event time is written into the connection end point. At the same time, the corresponding homology probability is written into the connection probability field. Starting with each event record as the initial node, candidate connections are recursively expanded according to the event time order. In each expansion level, only those with the highest probability of being from the same source are retained. The connection relationships form a controlled branch candidate chain expansion structure, in which... Taken from system configuration values; During the unfolding process, each unfolding path from the starting node to the ending node is determined as a candidate tracing sequence. The candidate tracing sequence consists of a list of event records arranged in chronological order and a corresponding list of records with the same probability of origin. Calculate the sequence consistency probability for each candidate trace sequence. The sequence consistency probability is written as , where the product term is the homology probability of adjacent event records in the candidate tracing sequence; The candidate traceability sequence set is formed by combining the homology probability of each adjacent event record in the sequence and the sequence consistency probability. The candidate traceability sequence set is output with the batch identifier as the index.
[0012] Optionally, performing Hirschberg global sequence alignment includes: The system receives a set of candidate traceability sequences as the first input and a process baseline sequence configured by the system as the second input. For each candidate traceability sequence, it reads a list of event records, a list of event types, and a list of homologous probabilities corresponding to adjacent event records arranged in chronological order. Let the list of candidate event types be denoted as The list of baseline event types corresponding to the baseline sequence of the process is denoted as... and for Create an index table that maps event types to location sets; Read the homology probability of adjacent event records in the candidate event type list. The homogeneity probability is written into the edge probability table, and the homogeneity probability is mapped to the matching cost term. ,in and will Write the candidate sequence cost table; Construct "candidate-benchmark" alignment feasible corridors before alignment computation and enforce their application during Hirschberg divide-and-conquer and dynamic programming computations: For each position in the candidate event type list Read event type Read from the index table exist The set of positions in the set, taking the minimum and maximum values of the set as... and ; When the location set is empty, Write as 1 and Write as ; When the set of positions is not empty, Write as And Write as ; Each Corresponding feasible interval Write it into the corridor table, and only apply it to any subsequent dynamic programming calculations that satisfy... reference position Write cost update: cells outside the corridor are written as unreachable. For each candidate tracing sequence, Hirschberg divide-and-conquer alignment is performed, specifically including: In the divide-and-conquer recursion, candidate subsequences are... At the midpoint Divided into left candidate subsequences With right candidate subsequence and for the same reference subsequence Calculate the forward generation value array and the backward generation value array respectively; When calculating the forward value array, only keep the array of length 0. A one-dimensional array and sorted by candidate position from Recursion to During the recursion of each candidate position, the array position is updated only within the interval defined by the corridor table. The array update involves four types of operations: matching, replacement, insertion, and deletion. Positions outside the corridor are marked as unreachable. When calculating the backward value array, the right candidate subsequence and the reference subsequence are reversed and the same one-dimensional array recursion is performed. Updates are also performed only within the corridor table's defined range, and unreachable flags are written at positions outside the corridor. The forward and backward value arrays are summed item by item at the same reference position to obtain the segmented value array; The selection of the split point involves transforming the "probability of homology" into a split point feasibility constraint and incorporating it into the deterministic selection rule, specifically including: For each candidate segmentation position in the segmentation cost array Read its segmentation value. When the position has an unreachable flag in the forward or backward array, write the position segmentation value into the unselectable flag. For positions where no unselectable markers are written, read the edge probabilities of the candidate sequence near the midpoint. ,when When the value is less than the second threshold, the location segmentation cost is written to the non-selectable flag, where the second threshold is taken from the system configuration value; Among the remaining possible positions, select the position with the minimum splitting cost as the splitting point. And when multiple minimum values exist, choose the one that makes the corridor interval width... Smaller positions as dividing points ; benchmark subsequence By dividing point Divided into left reference subsequences With right reference subsequence And recursively perform the same divide-and-conquer calculation on the left candidate subsequence and the left reference subsequence, and the right candidate subsequence and the right reference subsequence until the subsequence length is zero or one; The alignment path is generated during the recursion termination and backtracking phases, specifically including: When the length of the candidate subsequence is zero, write the insertion operation sequence according to the length of the reference subsequence; when the length of the reference subsequence is zero, write the deletion operation sequence according to the length of the candidate subsequence; when the length of the candidate subsequence and the length of the reference subsequence are both one, compare whether the event types are the same and write the matching or replacement operation. During the backtracking splicing process, the operation sequences generated by each subproblem are spliced together in the divide-and-conquer order to form a complete alignment operation sequence, and the alignment path is output according to the alignment operation sequence. The homo-origin probability corresponding to each candidate adjacent event record in the alignment path is read from the homo-origin probability record list and output along with the path. The alignment result is formed by outputting the alignment path, the sequence of alignment operations, and the cumulative alignment cost.
[0013] Optionally, the traceability results generated include: The first input is the alignment path and the alignment operation sequence, and the second input is the candidate tracing sequence and its corresponding record homology probability list. Based on the alignment operation sequence, and in accordance with the order of the process baseline sequence, the event records in the candidate traceability sequence are mapped one by one to the corresponding process positions. A vacancy mark is written at the position where the insertion, deletion or replacement operation occurs, forming a link mapping table containing the correspondence between process positions and event record identifiers. In the link mapping table, for each pair of adjacent process positions, the record homology probability between the corresponding event records is read, and the record homology probability is written into the link probability list in process order; The alignment operation sequence is traversed item by item, and the number of matching operations, replacement operations, insertion operations and deletion operations are counted respectively. Based on the statistical results, the proportion of matching operations in all alignment operations is calculated. Multiply the homo-source probabilities of all records in the link probability list in sequence to obtain the overall homo-source probability value corresponding to the link; When the proportion of matching operations is not less than the preset consistency threshold and the overall homogeneity probability value is not less than the preset homogeneity threshold, the link mapping table is determined as a valid traceability chain, and the traceability result is output. The traceability result includes at least the process position order, the corresponding event record identifier order, the link probability list, and the proportion of matching operations. When the proportion of matching operations is less than the preset consistency threshold or the overall homogeneity probability value is less than the preset homogeneity threshold, the link mapping table is marked as an unconfirmed traceability chain, and the unconfirmed traceability result containing the process position order, event record identification order, link probability list, matching operation proportion, and cumulative alignment cost is output.
[0014] The beneficial effects of this invention are: This invention introduces a method for calculating the probability of record homology based on the Fellegi-Sunter model. It quantifies the homology of traceability event records generated by different systems and stages, and maps multi-dimensional features such as subject, object, batch, event type and time into homology probability constraints. This effectively overcomes the shortcomings of existing technologies that rely on rules or single identifiers for coarse-grained matching, significantly reduces the probability of false and missed associations of cross-system events, and improves the objectivity and accuracy of traceability data association.
[0015] This invention employs the Hirschberg global sequence alignment method, combined with a business process benchmark and a homogeneous probability weighting mechanism, to perform consistent alignment between candidate tracing sequences and standard processes. This significantly reduces computational resource consumption while ensuring global optimality of alignment, effectively solving the problems of high memory consumption and low alignment efficiency in long sequence tracing. Attached Figure Description
[0016] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Fig. 1 This is a flowchart of a traditional Chinese medicine formula granule traceability system based on Internet of Things technology proposed in this invention; Fig. 2 This is a schematic diagram of the process for calculating the homogeneity probability of cross-system event records based on the Fellegi–Sunter model proposed in this invention. Detailed Implementation
[0017] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0018] refer to Figs. 1-2 A traceability system for traditional Chinese medicine formula granules based on Internet of Things (IoT) technology includes the following steps: The IoT event acquisition module acquires traceability event data from the raw materials, production, testing, circulation and use of traditional Chinese medicine formula granules, and generates an event data stream containing event time, subject identifier, object identifier, batch identifier and event type; The event normalization and sequence construction module performs time calibration and identifier parsing on the event data stream, and generates a standardized set of traceable event sequences with batch identifiers as constraints. The probability homology calculation module constructs candidate record pairs for cross-system event records in the standardized traceable event sequence set, and calculates the homology probability of records based on the Fellegi-Sunter model to form an association probability matrix; The probability-constrained candidate chain generation module uses the correlation probability matrix as a constraint to perform soft aggregation on the standardized traceability event sequence set, generating a candidate traceability sequence set carrying the probability of record homology; The probability-weighted consistency alignment module performs Hirschberg global sequence alignment between the candidate traceability sequence set and the preset process baseline sequence, and maps the probability of record homology to alignment cost and path feasibility constraints. The link confirmation and output module reconstructs the traceability chain based on the alignment results and outputs verifiable traceability results when the recorded homology probability and alignment consistency meet preset conditions.
[0019] In this embodiment, generating the event data stream includes: When raw materials are received, processed, inspected, transferred, or used, business data is obtained through the corresponding data collection terminal or business system interface. Each piece of business data includes at least the terminal identifier, the time of the business occurrence, the type of business operation, and the record of the business object. Read the time of the business occurrence from the business data, convert it into an event time according to a unified time format, and write the event time into the time field of the event record; Read the subject code corresponding to the current business operation from the business object record, and write the subject code into the subject identifier field of the event record. The subject code is taken from the subject information registered in the collection terminal or business system. Read the object code of the operated object from the business object record and write the object code into the object identifier field of the event record. The object code corresponds to the variety code, packaging unit code or distribution carrier code of the Chinese herbal medicine formula granules. Read the batch code associated with the current business operation from the business object record and write the batch code into the batch identifier field of the event record. The batch code is taken from one of the raw material batch number, production batch number, test batch number, circulation batch number or usage batch number. The event type is determined based on the business operation type, and the event type is written into the event type field of the event record, so that the operations of different business links are distinguished in the event record; The event record is formed by combining the event time, subject identifier, object identifier, batch identifier and event type, and multiple event records are continuously output in chronological order of the event time to generate an event data stream.
[0020] In this embodiment, generating a standardized traceability event sequence set includes: It reads the event records in the event data stream one by one, and each event record contains at least the event time, subject identifier, object identifier, batch identifier and event type; Perform time calibration on the event times in the event log, convert the event times to calibrated event times under the system time base, and replace the event time field in the event log with the calibrated event times; The subject identifier, object identifier, and batch identifier in the event record are parsed. The parsing process is limited to format standardization and legality verification of the identifier field. The parsed identifier results continue to be used as the subject identifier, object identifier, and batch identifier in the event record. The event records in the event data stream are grouped using the batch identifier in the event record as the grouping condition, and event records with the same batch identifier are grouped into the same event group; Within each event group, the event records are sorted according to the calibrated event time to generate an ordered list of event records with the corresponding batch identifier; The sorted list of event records within each event group is defined as a traceable event sequence, and the event records in the traceable event sequence are sequentially written with sequence position numbers. All traceable event sequences are aggregated to form a standardized traceable event sequence set, which is output with the batch identifier as the index.
[0021] In this embodiment, forming the correlation probability matrix includes: The standardized traceability event sequence set is used as input, and the event records in the traceability event sequence are read one by one. Each event record contains at least the event time, subject identifier, object identifier, batch identifier, event type, and record source system identifier. Within the range of event records with the same batch identifier, the event records are distinguished according to the record source system identifier. Candidate record pairs are constructed only between event records with different record source system identifiers, and each candidate record pair consists of two event records. For each candidate record pair, read the subject identifier, object identifier, event type and event time fields from the two event records, and generate a matching feature vector based on the field value relationship. The matching feature vector is composed of the field equality relationship and the event time difference. The matching feature vectors are used as input to the Fellegi–Sunter model. Based on the homology and non-homology hypotheses, the matching probability values corresponding to the matching feature vectors are calculated, and the homology probability of candidate record pairs is calculated based on the matching probability values. ; Using candidate record pairs as indices, the homology probability corresponding to each candidate record pair is written into the association probability matrix, and the matrix elements of the association probability matrix correspond one-to-one with the candidate record pairs. The correlation probability matrix is sent as output to the probability constraint candidate chain generation module, where the input of the correlation probability matrix is a set of standardized traceability event sequences.
[0022] In this embodiment, the Fellegi–Sunter model includes: Receive the generated set of candidate record pairs as input, and for each candidate record pair, read the subject identifier, object identifier, batch identifier, event type, event time, and record source system identifier of the first event record and the second event record; For each candidate record, a comparison status code is generated for each field. The comparison status code values are limited to A, D, and M. The subject identifier comparison status code is written as A when the subject identifiers of the two records are the same, D when the subject identifiers of the two records are different and both are not empty, and M when the subject identifier of at least one record is empty. The comparison status codes of object identifier, batch identifier, and event type are written according to the same rule. For each candidate record, compare the generated event time with the status code and calculate the event time difference between the two records. In both recorded events, the time is not empty and Write A when both record times are not empty and Write to D when the time is empty, and write to M when at least one record's event time is empty, time window. Taken from system configuration values; Write the comparison status code of subject identifier, object identifier, batch identifier, event type, and event time into the matching pattern vector in a fixed field order. and will Bind and store the corresponding candidate record pairs; During the model parameter construction phase, a set of homologous samples and a set of non-homologous samples are generated based on deterministic anchor pairs, and parameters are calculated accordingly. Filter the set of homologous anchor pairs within the candidate record pair set. The filtering criteria are limited to records whose source system identifiers are different, and whose object identifier comparison status code is A, event type comparison status code is A, event time comparison status code is A, and batch identifier comparison status code is A. Candidate records meeting these criteria are then written to... ; Filter the set of non-homologous anchor pairs within the candidate record pair set. The filtering criteria are limited to records whose source system identifiers are different, object identifier comparison status code is D, event type comparison status code is D, and batch identifier comparison status code is D. Candidate records meeting these criteria are then written to... ; right The comparison status codes of each field are counted separately to form a common-origin count table. ,in For field serial number and To compare status codes, and for Forming a non-homologous counting table ; Convert the homology count table into a homology matching probability table. The conversion method is limited to the serial number of each field. Calculate separately The non-same-origin count table is then converted into a non-same-origin matching probability table. The conversion method is limited to the serial number of each field. Calculate separately ; exist or When there is a zero count, the corresponding count value is written as 1, and the total count of the field number is increased by 3 before the probability table calculation is performed. Calculate the prior homology probability The prior homology probability is written as and will and Both are written into the model parameter set; During the probability calculation phase, candidate records are pruned for consistency before the same-origin probability calculation, and this consistency is written as an additional comparison field into the matching pattern vector. Read the system's configured process baseline sequence and establish a mapping table from event types to process position numbers. Write the position number corresponding to the event type of the first event record into the table. Write the position number corresponding to the event type of the second event record as... ; Calculate for each candidate record pair ,exist and Neither empty nor empty Write the process consistency comparison status code as A at that time. and Neither empty nor empty Write D when the position number cannot be obtained for at least one record, and write M when the position number cannot be obtained for the process consistency comparison status code, and append the process consistency comparison status code to the matching pattern vector. The end forms an extended matching pattern vector; For each candidate record pair, execute the pruning and writing rules. When the object identifier comparison status code is A and the batch identifier comparison status code is D, directly write the homology probability of the candidate record pair to 0 and mark it as calculated. When the event type comparison status code is D and the process consistency comparison status code is A, directly write the homology probability of the candidate record pair to 0 and mark it as calculated. For candidate record pairs not marked as having been computed, perform homology probability calculation, specifically including: Read the comparison status code field by field based on the extended matching pattern vector, and read the corresponding value from the model parameter set. And calculate the log-likelihood ratio weights. ,in: ; in, For field serial number The corresponding comparison status code; Based on weight Homology with prior Calculate the probability of homology and will Write the probability output item that corresponds one-to-one with the candidate record pair; Output candidate record pairs, extended matching pattern vectors, and homology probabilities to form a probability output set.
[0023] In this embodiment, the calculation of the forward cost array includes: after selecting candidate subsequences and reference subsequences in the alignment subproblem, a one-dimensional array with a length equal to the length of the reference subsequence plus one is established. The first element of the array is written as 0, and the remaining elements are sequentially written with the cost of "insertion once" from left to right according to the reference position as the initial row; candidate elements are processed one by one from left to right according to the position of the candidate subsequence. Each time a candidate element is processed, a new array is generated. The first element of the new array is written with the cost of "deletion once" based on the first element of the previous array. The remaining elements are updated sequentially from left to right according to the reference position. The update of each array element reads three source values at the same time: "deletion" corresponding to the element in the same column of the previous array, "insertion" corresponding to the element in the previous column of the current array, and "match or replacement" corresponding to the element in the previous column of the previous array. When the candidate element is the same as the element in the reference position, the "match" cost is used, otherwise the "replace" cost is used; the corresponding operation cost is added to the above three source values respectively, and the minimum value is written to the array element, thereby obtaining the minimum cumulative cost array for aligning the first half of the candidate subsequence with each prefix of the reference subsequence; The calculation of the backward value array specifically includes: processing the second half of the candidate subsequence and the reference subsequence in the opposite direction, first performing a reverse traversal on both, using the same one-dimensional array initialization and element-by-element update rules as the forward value array to calculate the reverse minimum cumulative cost array, and then restoring the reverse array to the original direction according to the reference position, which is used to represent the minimum cumulative cost of aligning the second half of the candidate with each suffix of the reference.
[0024] In this embodiment, the method for generating a candidate tracing sequence set includes: It receives a standardized set of traceable event sequences as the first input, an association probability matrix as the second input, and reads the event time, event type, and record source system identifier of the event records within the same batch identifier range; Within the same batch of event record sets, only among event records whose event times satisfy the chronological order constraint and whose record source system identifiers are different, the corresponding homologous probabilities are read based on the association probability matrix to construct directed candidate connections. For each directed candidate connection, it is retained only if its homology probability is not less than the first threshold. The event record with the earlier event time is written into the connection start point and the event record with the later event time is written into the connection end point. At the same time, the corresponding homology probability is written into the connection probability field. Starting with each event record as the initial node, candidate connections are recursively expanded according to the event time order. In each expansion level, only those with the highest probability of being from the same source are retained. The connection relationships form a controlled branch candidate chain expansion structure, in which... Taken from system configuration values; During the unfolding process, each unfolding path from the starting node to the ending node is determined as a candidate tracing sequence. The candidate tracing sequence consists of a list of event records arranged in chronological order and a corresponding list of records with the same probability of origin. Calculate the sequence consistency probability for each candidate trace sequence. The sequence consistency probability is written as , where the product term is the homology probability of adjacent event records in the candidate tracing sequence; The candidate traceability sequence set is formed by combining the homology probability of each adjacent event record in the sequence and the sequence consistency probability. The candidate traceability sequence set is output with the batch identifier as the index.
[0025] In this embodiment, performing Hirschberg global sequence alignment includes: The system receives a set of candidate traceability sequences as the first input and a process baseline sequence configured by the system as the second input. For each candidate traceability sequence, it reads a list of event records, a list of event types, and a list of homologous probabilities corresponding to adjacent event records arranged in chronological order. Let the list of candidate event types be denoted as The list of baseline event types corresponding to the baseline sequence of the process is denoted as... and for Create an index table that maps event types to location sets; Read the homology probability of adjacent event records in the candidate event type list. The homogeneity probability is written into the edge probability table, and the homogeneity probability is mapped to the matching cost term. ,in and will Write the candidate sequence cost table; Constructing a "candidate-benchmark" alignment feasible corridor before alignment computation and forcibly applying it in Hirschberg divide-and-conquer and dynamic programming computations includes: For each position in the candidate event type list Read event type Read from the index table exist Given a set of positions in the set, take the minimum and maximum values of that set as... and ; When the location set is empty, Write as 1 and Write as ; When the set of positions is not empty, Write as And Write as ; Each Corresponding feasible interval Write it into the corridor table, and only apply it to any subsequent dynamic programming calculations that satisfy... reference position Write cost update: cells outside the corridor are written as unreachable. For each candidate tracing sequence, Hirschberg divide-and-conquer alignment is performed, specifically including: In the divide-and-conquer recursion, candidate subsequences are... At the midpoint Divided into left candidate subsequences With right candidate subsequence and for the same reference subsequence Calculate the forward generation value array and the backward generation value array respectively; When calculating the forward value array, only keep the array of length 0. A one-dimensional array and sorted by candidate position from Recursion to During the recursion of each candidate position, the array position is updated only within the interval defined by the corridor table. The array update involves four types of operations: matching, replacement, insertion, and deletion. Positions outside the corridor are marked as unreachable. When calculating the backward value array, the right candidate subsequence and the reference subsequence are reversed and the same one-dimensional array recursion is performed. Updates are also performed only within the corridor table's defined range, and unreachable flags are written at positions outside the corridor. The forward and backward value arrays are summed item by item at the same reference position to obtain the segmented value array; During the split point selection phase, the "probability of recording homology" is transformed into a split point feasibility constraint and written into the deterministic selection rule: For each candidate segmentation position in the segmentation cost array Read its segmentation value. If the position has an unreachable flag in the forward or backward array, write the segmentation value of that position to the unselectable flag. For positions where no unselectable markers are written, read the edge probabilities of the candidate sequence near the midpoint. ,when When the value is less than the second threshold, the cost of segmenting that position is written to the non-selectable flag, where the second threshold is taken from the system configuration value; Among the remaining possible positions, select the position with the minimum splitting cost as the splitting point. And when multiple minimum values exist, choose the one that makes the corridor interval width... Smaller positions as dividing points ; benchmark subsequence By dividing point Divided into left reference subsequences With right reference subsequence And recursively perform the same divide-and-conquer calculation on the left candidate subsequence and the left reference subsequence, and the right candidate subsequence and the right reference subsequence until the subsequence length is zero or one; The alignment path is generated during the recursion termination and backtracking phases, specifically including: When the length of the candidate subsequence is zero, write the insertion operation sequence according to the length of the reference subsequence; when the length of the reference subsequence is zero, write the deletion operation sequence according to the length of the candidate subsequence; when the length of the candidate subsequence and the length of the reference subsequence are both one, compare whether the event types are the same and write the matching or replacement operation. During the backtracking splicing process, the operation sequences generated by each sub-problem are spliced together in the divide-and-conquer order to form a complete alignment operation sequence, and the alignment path is output according to the alignment operation sequence. The homology probability corresponding to the connection of each candidate adjacent event record in the alignment path is read from the homology probability list of claim 6 and output along with the path. The alignment result is formed by outputting the alignment path, the sequence of alignment operations, and the cumulative alignment cost.
[0026] In this embodiment, generating traceability results includes: The first input is the alignment path and the alignment operation sequence, and the second input is the candidate tracing sequence and its corresponding record homology probability list. Based on the alignment operation sequence, and in accordance with the order of the process baseline sequence, the event records in the candidate traceability sequence are mapped one by one to the corresponding process positions. A vacancy mark is written at the position where the insertion, deletion or replacement operation occurs, forming a link mapping table containing the correspondence between process positions and event record identifiers. In the link mapping table, for each pair of adjacent process positions, the record homology probability between the corresponding event records is read, and the record homology probability is written into the link probability list in process order. The alignment operation sequence is traversed item by item, and the number of matching operations, replacement operations, insertion operations and deletion operations are counted respectively. Based on the statistical results, the proportion of matching operations in all alignment operations is calculated. Multiply the homo-source probabilities of all records in the link probability list in turn to obtain the overall homo-source probability value corresponding to the link; When the proportion of matching operations is not less than the preset consistency threshold and the overall homogeneity probability value is not less than the preset homogeneity threshold, the link mapping table is determined as a valid traceability chain, and the traceability result is output. The traceability result includes at least the process position order, the corresponding event record identifier order, the link probability list, and the proportion of matching operations. When the proportion of matching operations is less than the preset consistency threshold or the overall homogeneity probability value is less than the preset homogeneity threshold, the link mapping table is marked as an unconfirmed traceability chain, and the unconfirmed traceability result containing the process position order, event record identification order, link probability list, matching operation proportion, and cumulative alignment cost is output.
[0027] Example: To verify the practical feasibility of the TCM formula granule traceability system based on IoT technology in a complex business environment, the system was deployed in a complete business scenario covering the receipt of raw materials, production and processing, quality inspection, warehousing and circulation, and end-user use of TCM formula granules. In this scenario, TCM formula granules circulate among multiple business entities, with different stages supported by independent information systems. There are no unified data standards or unified process control logic among the business systems, forming a typical traceability environment with multiple systems, multiple batches, and multiple paths operating in parallel.
[0028] In this business scenario, the first business record is generated once the raw materials for traditional Chinese medicine enter the production system. Subsequently, new business data is continuously generated during processing, inspection, packaging, warehousing, outbound delivery, and use. This business data is scattered across different systems. Some data is automatically collected by IoT terminals, while some is written by the business systems after operations are completed. This results in record delays, time offsets, and missing fields. Traditional traceability methods simply connect records based on batch numbers. When multiple similar records of the same batch appear in different systems, it is impossible to accurately determine the true correspondence, easily leading to problems such as traceability path forks or incorrect splicing.
[0029] In this embodiment, the IoT event acquisition module of the present invention is deployed at the business system interfaces and acquisition terminals of each stage of raw materials, production, testing, distribution, and use. When any business operation occurs, the acquisition module reads the business occurrence time, business subject information, operated object information, and batch-related information from the corresponding system in real time, and generates a corresponding event type tag according to the actual type of business operation. The acquisition module combines the above information to form a traceability event record and outputs the event data stream continuously in chronological order, thereby realizing a unified event-based expression of operations in different business stages at the system level.
[0030] After the generated event data stream enters the event normalization and sequence construction module, the system first performs unified calibration on the event times, mapping event records from different systems to the same time base and avoiding sequence errors caused by system clock deviations. Subsequently, the system parses and performs format standardization verification on the subject identifier, object identifier, and batch identifier, making data with previously differing codes structurally comparable. After normalization, the system groups event records using the batch identifier as a constraint and sorts them within each group according to the calibrated event times, forming a traceable event sequence with a clear sequential relationship. This process organizes scattered events from the same batch generated in different systems into a logically continuous basic sequence, providing stable input for subsequent correlation calculations.
[0031] In the cross-system event association phase, the probabilistic homology calculation module further processes event records in the standardized traceable event sequence. Within the same batch, the system constructs candidate record pairs only for event records from different source systems, thus avoiding repeated comparisons of records within the same system. For each candidate record pair, the system extracts fields such as subject identifier, object identifier, event type, and event time, generates a matching feature vector based on the field value relationships, and inputs this vector into a probabilistic calculation framework built on the Fellegi-Sunter model. The model calculates the matching probability under both homology and non-homology assumptions and outputs the record homology probability value, ensuring that each pair of cross-system records obtains a quantifiable homology assessment result. In this way, even if some fields are missing or there are slight inconsistencies, the system can still determine the true degree of association between records based on the overall feature relationships.
[0032] The resulting homology probabilities are written into the association probability matrix and input as constraints to the probability constraint candidate chain generation module. This module constructs directed candidate connections within the same batch of corresponding event records based on the chronological order of events and the homology probability threshold, retaining only connections that satisfy the homology probability condition and explicitly carrying the corresponding probability value in the connection relationship. Based on this, the system recursively expands the candidate connections from different starting events, generating multiple candidate tracing sequences carrying probability information. This process avoids the combinatorial explosion problem caused by simple full connections in traditional tracing methods, keeping the number of candidate chains always within a controllable range.
[0033] The generated candidate traceability sequences are input into a probability-weighted consistency alignment module, which pre-loads the standard production and circulation process of traditional Chinese medicine formula granules as the process baseline sequence. The system uses the Hirschberg global sequence alignment method to perform alignment calculations between the candidate traceability sequences and the process baseline, mapping the homology probability between adjacent event records to alignment costs and path feasibility constraints. During the alignment process, the system limits the search space by constructing alignment feasible corridors, significantly reducing memory consumption while ensuring globally optimal alignment results, enabling the system to stably handle long traceability sequences containing a large number of event nodes. Through this alignment mechanism, the system can identify matching, replacement, insertion, and deletion relationships between candidate chains and standard processes, thereby determining the rationality of the chain at the process level.
[0034] During the link confirmation and output phase, the system reconstructs the complete traceability chain based on the alignment results and comprehensively evaluates the probability of common origin of records for adjacent events in the chain, as well as the overall alignment consistency. When a chain simultaneously meets preset conditions at both the probability and process consistency levels, the system confirms the chain as a valid traceability result and outputs it; otherwise, it is marked as an unconfirmed link for subsequent analysis. This mechanism makes the traceability results themselves verifiable, avoiding the problem of traditional systems outputting all results indiscriminately and making it difficult to distinguish credibility.
[0035] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A traceability system for traditional Chinese medicine formula granules based on Internet of Things (IoT) technology, characterized in that, include: The event acquisition module obtains traceability event data from the raw materials, production, testing, circulation and use of traditional Chinese medicine formula granules, and generates an event data stream; The event normalization and sequence construction module performs time calibration and identifier parsing on the event data stream, and generates a standardized set of traceable event sequences with batch identifiers as constraints. The probability homology calculation module constructs candidate record pairs for cross-system event records in the standardized traceable event sequence set, and calculates the homology probability of records based on the Fellegi-Sunter model to form an association probability matrix; The candidate chain generation module uses the correlation probability matrix as a constraint to perform soft aggregation on the standardized traceability event sequence set to generate a candidate traceability sequence set. The alignment module performs Hirschberg global sequence alignment between the candidate traceability sequence set and the preset process baseline sequence, and maps the record homology probability to alignment cost and path feasibility constraints. The output module reconstructs the traceability chain based on the alignment results and outputs verifiable traceability results when the recorded homology probability and alignment consistency meet preset conditions.
2. The traceability system for traditional Chinese medicine formula granules based on Internet of Things technology according to claim 1, characterized in that, Generating a standardized set of traceable event sequences includes: The event data stream is taken as input, and the event records in the event data stream are read one by one. Perform time calibration on the event times in the event log, convert the event times to calibrated event times under the system time base, and replace the event time field in the event log with the calibrated event times; The subject identifier, object identifier, and batch identifier in the event record are parsed. The parsing process is limited to format standardization and legality verification of the identifier field. The parsed identifier results continue to be used as the subject identifier, object identifier, and batch identifier in the event record. The event records in the event data stream are grouped using the batch identifier in the event record as the grouping condition, and event records with the same batch identifier are grouped into the same event group; Within each event group, the event records are sorted according to the calibrated event time to generate an ordered list of event records with the corresponding batch identifier; The sorted list of event records within each event group is defined as a traceable event sequence, and the event records in the traceable event sequence are sequentially written with sequence position numbers. All traceable event sequences are aggregated to form a standardized traceable event sequence set, which is output with the batch identifier as the index.
3. The traceability system for traditional Chinese medicine formula granules based on Internet of Things technology according to claim 1, characterized in that, Generating the association probability matrix includes: Read the event records in the tracing event sequence one by one; Within the range of event records with the same batch identifier, the event records are distinguished according to the record source system identifier. Candidate record pairs are constructed only between event records with different record source system identifiers, and each candidate record pair consists of two event records. For each candidate record pair, read the subject identifier, object identifier, event type and event time fields from the two event records, and generate a matching feature vector based on the field value relationship. The matching feature vector is composed of the field equality relationship and the event time difference. The candidate record pair set is used as input to the Fellegi–Sunter model. Matching probabilities are calculated based on both the homology and non-homology hypotheses for the matching feature vectors. Finally, the homology probability of the candidate record pairs is calculated based on these matching probabilities. ; Using candidate record pairs as indices, the homology probability corresponding to each candidate record pair is written into the association probability matrix, and the matrix elements of the association probability matrix correspond one-to-one with the candidate record pairs.
4. The traceability system for traditional Chinese medicine formula granules based on Internet of Things technology according to claim 3, characterized in that, The Fellegi–Sunter model includes: Receive the generated set of candidate record pairs as input, and for each candidate record pair, read the subject identifier, object identifier, batch identifier, event type, event time, and record source system identifier of the first event record and the second event record; For each candidate record, a comparison status code is generated for each field. The comparison status code values are limited to A, D, and M. The subject identifier comparison status code is written as A when the subject identifiers of the two records are the same, D when the subject identifiers of the two records are different and both are not empty, and M when the subject identifier of at least one record is empty. The comparison status codes of object identifier, batch identifier, and event type are written according to the same rule. For each candidate record, compare the generated event time with the status code and calculate the event time difference between the two records. In both recorded events, the time is not empty and Write A when both record times are not empty and Write to D when the time is empty, and write to M when at least one record's event time is empty, time window. Taken from system configuration values; Write the comparison status code of subject identifier, object identifier, batch identifier, event type, and event time into the matching pattern vector in a fixed field order. and will Bind and store the corresponding candidate record pairs; Execute during the model parameter building phase: Filter the set of homologous anchor pairs within the candidate record pair set. The filtering criteria are limited to records whose source system identifiers are different, and whose object identifier comparison status code is A, event type comparison status code is A, event time comparison status code is A, and batch identifier comparison status code is A. Candidate records meeting these criteria are then written to... ; Filter the set of non-homologous anchor pairs within the candidate record pair set. The filtering criteria are limited to records whose source system identifiers are different, object identifier comparison status code is D, event type comparison status code is D, and batch identifier comparison status code is D. Candidate records meeting these criteria are then written to... ; right The comparison status codes of each field are counted separately to form a common-origin count table. ,in For field serial number and To compare status codes, and for Forming a non-homologous counting table ; Convert the homology count table into a homology matching probability table. The conversion method is limited to the serial number of each field. Calculate separately The non-same-origin count table is then converted into a non-same-origin matching probability table. The conversion method is limited to the serial number of each field. Calculate separately ; exist or When there is a zero count, the corresponding count value is written as 1, and the total count of the field sequence number is increased by 3 before the probability table calculation is performed. Calculate the prior homology probability The prior homology probability is written as and will and Both are written into the model parameter set; Executed during the probability calculation phase: Read the system's configured process baseline sequence and establish a mapping table from event types to process position numbers. Write the position number corresponding to the event type of the first event record into the table. Write the position number corresponding to the event type of the second event record as... ; Calculate for each candidate record pair ,exist and Neither empty nor empty Write the process consistency comparison status code as A at that time. and Neither empty nor empty Write D when the position number cannot be obtained for at least one record, and write M when the position number cannot be obtained for the process consistency comparison status code, and append the process consistency comparison status code to the matching pattern vector. The end forms an extended matching pattern vector; For each candidate record pair, a pruning and writing rule is executed. When the object identifier comparison status code is A and the batch identifier comparison status code is D, the homology probability of the candidate record pair is directly written to 0 and marked as calculated. When the event type comparison status code is D and the process consistency comparison status code is A, the homology probability of the candidate record pair is directly written to 0 and marked as calculated. For candidate record pairs not marked as having been computed, perform homology probability calculation, specifically including: Read the comparison status code field by field based on the extended matching pattern vector, and read the corresponding value from the model parameter set. And calculate the log-likelihood ratio weights. : ; in, For field serial number The corresponding comparison status code; Based on weight Homology with prior Calculate the probability of homology and will Write the probability output item that corresponds one-to-one with the candidate record pair.
5. A traceability system for traditional Chinese medicine formula granules based on Internet of Things technology according to claim 1, characterized in that, Methods for generating candidate traceability sequence sets include: It receives a standardized set of traceable event sequences as the first input, an association probability matrix as the second input, and reads the event time, event type, and record source system identifier of the event records within the same batch identifier range; Within the same batch of event record sets, only among event records whose event times satisfy the chronological order constraint and whose record source system identifiers are different, the corresponding homologous probabilities are read based on the association probability matrix to construct directed candidate connections. For each directed candidate connection, it is retained only if its homology probability is not less than the first threshold. The event record with the earlier event time is written into the connection start point and the event record with the later event time is written into the connection end point. At the same time, the corresponding homology probability is written into the connection probability field. Starting with each event record as the initial node, candidate connections are recursively expanded according to the event time order. In each expansion level, only those with the highest probability of being from the same source are retained. The connection relationships form a controlled branch candidate chain expansion structure, in which... Taken from system configuration values; During the unfolding process, each unfolding path from the starting node to the ending node is determined as a candidate tracing sequence. The candidate tracing sequence consists of a list of event records arranged in chronological order and a corresponding list of records with the same probability of origin. Calculate the sequence consistency probability for each candidate trace sequence. The sequence consistency probability is written as , where the product term is the homology probability of adjacent event records in the candidate tracing sequence; The candidate traceability sequence set is formed by combining the homology probability of each adjacent event record in the sequence and the sequence consistency probability. The candidate traceability sequence set is output with the batch identifier as the index.
6. A traceability system for traditional Chinese medicine formula granules based on Internet of Things technology according to claim 1, characterized in that, Performing Hirschberg global sequence alignment includes: The system receives a set of candidate traceability sequences as the first input and a process baseline sequence configured by the system as the second input. For each candidate traceability sequence, it reads a list of event records, a list of event types, and a list of homologous probabilities corresponding to adjacent event records arranged in chronological order. Let the list of candidate event types be denoted as The list of baseline event types corresponding to the baseline sequence of the process is denoted as... and for Create an index table that maps event types to location sets; Read the homology probability of adjacent event records in the candidate event type list. The homogeneity probability is written into the edge probability table, and the homogeneity probability is mapped to the matching cost term. ,in and will Write the candidate sequence cost table; Construct "candidate-benchmark" alignment feasible corridors before alignment computation and enforce their application during Hirschberg divide-and-conquer and dynamic programming computations: For each position in the candidate event type list Read event type Read from the index table exist The set of positions in the set, taking the minimum and maximum values of the set as... and ; When the location set is empty, Write as 1 and Write as ; When the set of positions is not empty, Write as And Write as ; Each Corresponding feasible interval Write it into the corridor table, and only apply it to any subsequent dynamic programming calculations that satisfy... reference position Write cost update: cells outside the corridor are written as unreachable. For each candidate tracing sequence, Hirschberg divide-and-conquer alignment is performed, specifically including: In the divide-and-conquer recursion, candidate subsequences are... At the midpoint Divided into left candidate subsequences With right candidate subsequence and for the same reference subsequence Calculate the forward generation value array and the backward generation value array respectively; When calculating the forward value array, only the array of length 0 is retained. A one-dimensional array and sorted by candidate position from Recursion to During the recursion of each candidate position, the array position is updated only within the interval defined by the corridor table. The array update involves four types of operations: matching, replacement, insertion, and deletion. Positions outside the corridor are marked as unreachable. When calculating the backward value array, the right candidate subsequence and the reference subsequence are reversed and the same one-dimensional array recursion is performed. Updates are also performed only within the corridor table's defined range, and unreachable flags are written at positions outside the corridor. The forward and backward value arrays are summed item by item at the same reference position to obtain the segmented value array; The selection of the split point transforms the "probability of homology" into a split point feasibility constraint and incorporates it into the deterministic selection rule, specifically including: For each candidate segmentation position in the segmentation cost array Read its segmentation value. When the position has an unreachable flag in the forward or backward array, write the position segmentation value into the unselectable flag. For positions where no unselectable markers are written, read the edge probabilities of the candidate sequence near the midpoint. ,when When the value is less than the second threshold, the location segmentation cost is written to the non-selectable flag, where the second threshold is taken from the system configuration value; Among the remaining possible positions, select the position with the minimum splitting cost as the splitting point. And when multiple minimum values exist, choose the one that makes the corridor interval width... Smaller positions as dividing points ; benchmark subsequence By dividing point Divided into left reference subsequences With right reference subsequence And recursively perform the same divide-and-conquer calculation on the left candidate subsequence and the left reference subsequence, and the right candidate subsequence and the right reference subsequence until the subsequence length is zero or one; The alignment path is generated during the recursion termination and backtracking phases, specifically including: When the length of the candidate subsequence is zero, write the insertion operation sequence according to the length of the reference subsequence; when the length of the reference subsequence is zero, write the deletion operation sequence according to the length of the candidate subsequence; when the length of the candidate subsequence and the length of the reference subsequence are both one, compare whether the event types are the same and write the matching or replacement operation. During the backtracking splicing process, the operation sequences generated by each subproblem are spliced together in the divide-and-conquer order to form a complete alignment operation sequence, and the alignment path is output according to the alignment operation sequence. The homo-origin probability corresponding to each candidate adjacent event record in the alignment path is read from the homo-origin probability record list and output along with the path. The alignment result is formed by outputting the alignment path, the sequence of alignment operations, and the cumulative alignment cost.
7. A traceability system for traditional Chinese medicine formula granules based on Internet of Things technology according to claim 1, characterized in that, The generated traceability results include: The first input is the alignment path and the alignment operation sequence, and the second input is the candidate tracing sequence and its corresponding record homology probability list. Based on the alignment operation sequence, and in accordance with the order of the process baseline sequence, the event records in the candidate traceability sequence are mapped one by one to the corresponding process positions. A vacancy mark is written at the position where the insertion, deletion or replacement operation occurs, forming a link mapping table containing the correspondence between process positions and event record identifiers. In the link mapping table, for each pair of adjacent process positions, the record homology probability between the corresponding event records is read, and the record homology probability is written into the link probability list in process order; The alignment operation sequence is traversed item by item, and the number of matching operations, replacement operations, insertion operations and deletion operations are counted respectively. Based on the statistical results, the proportion of matching operations in all alignment operations is calculated. Multiply the homo-source probabilities of all records in the link probability list in sequence to obtain the overall homo-source probability value corresponding to the link; When the proportion of matching operations is not less than the preset consistency threshold and the overall homogeneity probability value is not less than the preset homogeneity threshold, the link mapping table is determined as a valid traceability chain, and the traceability result is output. The traceability result includes at least the process position order, the corresponding event record identifier order, the link probability list, and the proportion of matching operations. When the proportion of matching operations is less than the preset consistency threshold or the overall homogeneity probability value is less than the preset homogeneity threshold, the link mapping table is marked as an unconfirmed traceability chain, and the unconfirmed traceability result containing the process position order, event record identification order, link probability list, matching operation proportion, and cumulative alignment cost is output.