A storage method for efficient and intelligent matching of ships and cargoes
By partitioning and matching port, vessel, and cargo information in Redis, the problem of low efficiency in existing vessel-cargo matching systems is solved. This enables efficient and intelligent matching of vessel and cargo information across multiple loading and unloading points, improving system performance and matching speed.
Patent Information
- Application Number
- CN202111561226.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-12-16
AI Technical Summary
In the case of large amounts of data, existing ship-cargo matching systems have poor performance and cannot quickly and effectively match ship and cargo information with multiple loading and unloading points, resulting in low system efficiency.
The data storage method based on Redis caching is adopted, which divides port, ship and cargo information into three major categories and stores them in the port data area, ship data area and cargo data area of Redis respectively. Through reasonable data structure and matching algorithm, efficient matching is performed when information is published, reducing the frequency of database access.
It achieves efficient and intelligent ship-cargo matching under large data volumes, improves system performance and matching speed, reduces database query pressure, and supports high-concurrency processing.
Smart Images

Figure CN114416788B
Abstract
Description
Technical Field
[0001] The present application relates to the field of online freight industry or logistics and transportation industry, and in particular to a storage method for efficient and intelligent matching of ships and cargoes. Background Art
[0002] In logistics activities, the empty ship information (ship plate) released by the shipowner and the shipping information (cargo pallet) released by the cargo owner often involve the problem of intelligent matching in a system. The conventional idea is that when the shipowner releases the ship plate information, all the cargo pallets whose loading place is the empty ship place are searched in the cargo owner's cargo pallet data table as matching source orders. Similarly, when the cargo owner releases the cargo pallet information, all the cargo pallets whose empty ship place is the source of cargo and shipping place are searched in the shipowner's cargo pallet data table as matching idle ships. Although this logic is simple, there is a serious problem. When the amount of cargo pallet and cargo plate data is large, it is bound to cause frequent searches for database data, resulting in extremely low system performance and efficiency, and the search data cannot be responded in time, especially when the shipowner can have multiple empty ship places and the unloading place can also run multiple locations. There is no common method that can adapt well to multiple loading places and unloading places, and can match quickly and effectively at the same time. The present invention is to solve the method of efficient and intelligent ship-cargo matching under large data volume conditions, so as to adapt to the real-time empty ship release needs and cargo distribution notifications of hundreds of thousands of cargo ships in China. Summary of the invention
[0003] The purpose of the present invention is to provide a storage method for efficient and intelligent matching of ships and cargoes, so as to overcome the deficiencies in the prior art.
[0004] To achieve the above object, the present invention provides the following technical solution: a storage method for efficient and intelligent matching of ships and cargoes, based on high-speed cache redis, comprising:
[0005] Step 1: Load the port data into the port data area of redis;
[0006] Step 2: When the empty ship disk information is released, the empty ship disk basic information is stored in the basic information in the redis ship data area, and the expiration time is set; at the same time, the empty ship disk ID is added to the ship list in the redis port data area;
[0007] Step 3: Get the cargo source ID list corresponding to the empty ship port in the redis port data area, obtain the corresponding cargo source information from the redis cargo source data area through the cargo source ID, and match it with the empty ship order information one by one;
[0008] Step 4: When the empty ship order information matches the cargo source information, the cargo source ID is added to the list of empty ship ports corresponding to the empty ship order ID in the redis ship data area that matches the cargo source ID of the ship;
[0009] Step 5: When the empty ship order information is cancelled, the empty ship order ID is removed from the redis port data area; at the same time, the empty ship order ID is removed from the redis cargo source data area;
[0010] Step 6: When the pallet information is released, the basic information of the pallet is stored in the redis source data area and an expiration time is set;
[0011] At the same time, the pallet ID is added to the cargo source ID list in the redis port data area;
[0012] Step 7: Get the ship ID list corresponding to the departure port in the redis port data area, obtain the corresponding ship information from the redis ship data area through the ship ID, and match it with the pallet information one by one;
[0013] Step 8: When the cargo information matches the ship information, add the ship ID to the list of ship IDs that match the cargo source at the corresponding port of departure in the cargo source ID in the redis cargo source data area;
[0014] Step 9: When the pallet information is cancelled, the pallet ID is removed from the source list of the departure port and surrounding ports in the redis port data area.
[0015] Preferably, the port data includes: port name, surrounding port ID list, cargo source ID list and empty vessel ID list.
[0016] Preferably, the empty ship information includes: basic information, a list of cargo source IDs matching the empty ship port and a list of cargo source IDs matching the empty ship port's surrounding ports. The basic information includes: loading time, cargo volume and deadweight tonnage, loading and unloading ports, ship type, and navigation area.
[0017] Preferably, the cargo pallet information includes: basic information, a list of ship IDs matching the cargo source at the port of departure, and a list of ship IDs matching the cargo source at ports surrounding the port of departure, and the basic information includes: loading time, cargo volume and deadweight tonnage, loading and unloading ports, ship type, and navigation area.
[0018] Preferably, step 3 further comprises: when the empty vessel information includes surrounding port information of empty discharge and empty loading, the empty vessel ID is added to the ship list of ports surrounding the empty port in the redis port data area, the list of source IDs of ports surrounding the empty port in the redis port data area is obtained, the corresponding source information is obtained from the redis source data area through the source ID, and the information is matched with the empty vessel information one by one.
[0019] Preferably, step 7 also includes: when the port of departure in the pallet information includes surrounding ports, adding the pallet ID to the corresponding source ID list of the surrounding ports in the redis port data area, obtaining the ship ID list of the surrounding ports in the redis port data area, obtaining the ship information through the ship ID list, and matching it with the pallet information one by one.
[0020] Compared with the prior art, the storage method for efficient and intelligent matching of ships and cargoes of the present application can effectively organize and utilize data and associate them with each other, so that an efficient matching process can be performed at the time of publication, achieving matching upon publication, and effectively solving the speed problem of big data matching; at the same time, data is stored in a high-speed cache to avoid frequent database reading and reduce the pressure on accessing the database server, which can greatly improve system performance and intelligent matching speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application 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, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 A data type diagram of a storage method for efficient and intelligent matching of ships and cargoes according to a specific embodiment of the present invention;
[0023] Figure 2 A schematic diagram of port data of a storage method for efficient and intelligent matching of ships and cargoes according to a specific embodiment of the present invention;
[0024] Figure 3 A schematic diagram of empty ship data of a storage method for efficient and intelligent matching of ships and cargoes according to a specific embodiment of the present invention
[0025] Figure 4 The present invention is a schematic diagram of cargo source data of a storage method for efficient and intelligent matching of ships and cargoes according to a specific embodiment of the present invention. DETAILED DESCRIPTION
[0026] The following will describe the technical solutions in the embodiments of the present invention in detail in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] The present invention combines data caching technology to store the data required for matching in redis. Through effective data structure organization and caching, the matching process is moved forward, that is, the matching step of searching for data in the database after the information is released is moved forward to directly matching when the data is released for storage. Thanks to the reasonable data structure and redis cache, there is no need to search frequently in the database, and the key can be intelligently matched directly in the memory, which greatly reduces the query pressure of the database, achieves high efficiency and intelligence, and supports high concurrent processing.
[0028] Combination Figure 1 As shown in the figure, to achieve efficient and intelligent matching, it is necessary to classify the data first and organize the logical relationship of the data reasonably. From the perspective of ship-cargo matching data, it is mainly divided into three categories: port data, empty ship data, and cargo source data. To match empty ship data and cargo source data, they are all associated through the corresponding loading port.
[0029] Redis is a key-value storage system. Similar to Memcached, it supports storing more value types, including string, list, set, zset (sortedset), and hash. These data types support push / pop, add / remove, intersection, union, difference, and richer operations, and these operations are atomic. On this basis, Redis supports various different sorting methods. Like Memcached, in order to ensure efficiency, data is cached in memory. The difference is that Redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, master-slave synchronization is implemented.
[0030] The three categories of matching data are all stored in redis, corresponding to the port data area, the ship data area, and the cargo data area. The key of the port data area starts with area_id, the key of the ship data area starts with ship_id, and the key of the cargo data area starts with goods_id.
[0031] Combination Figure 2 As shown, 1. Port data: Each port needs to be assigned a code: area_id. Each port is a port node block. The node block data items include static data and dynamic data.
[0032] 1.1 Static data includes: port code (area_id), port name (area_name), nearby port list (near_list). Static data changes infrequently. All ports along the Yangtze River Canal are coded, pre-configured into the system, and loaded into redis when the system starts. If the port code is added or deleted, it is updated to redis by reloading.
[0033] Static data is stored in redis with each port as a data group item and the port code as the variable factor to form the key. The surrounding ports are used to record which port IDs are the surrounding ports of the current port, and are used to publish the ship cargo pallet to the surrounding ports at the same time, so that multiple empty ports can also match the corresponding data.
[0034] 1.2 Dynamic data includes: goods id list (goods_id) and empty ship id list (ship_id)
[0035] The cargo source (empty ship) id list records the published cargo origin (empty ship port) which is the data list of the port id. It is stored in redis as key-value pairs, logically forming a cargo source (empty ship) id list. Each key-value has a TTL time to store the validity period of the cargo source (empty ship). The redis system mechanism will automatically clean up expired cargo source (empty ship) ids according to the validity period.
[0036] The port coded as 103206 has 4 sources
[0037] id(100226157,100226162,100226201,100226208), 2 empty ship ids(1010097,1017017)
[0038] The important role of storing the cargo source ID list and ship ID list belonging to the port here is to match the rules for each cargo (ship) ID in the cargo source (ship) ID list when publishing the ship plate (cargo plate) of this node port. If it meets the matching principle, it is considered a successful match. Once these reasonable data are organized to generate an accurate data list, there is no need to search for a large amount of data in the database table, which is time-consuming.
[0039] Combination Figure 3 As shown, 2. Empty ship data: Each ship needs to be assigned a code ship_id. When the shipowner publishes an empty ship disk, the empty ship data will be stored in redis as a node data. The stored data includes: static data and dynamic data.
[0040] 2.1 Static data includes: basic information such as ship name and tonnage, empty port area_id, empty start time, empty end time, list of adjacent ports area_id that can receive cargo, list of destination port area_id
[0041] Static data is stored in redis with each ship as a data group item and the ship ID code as the variable factor to form the key.
[0042] 2.2 Dynamic data includes: the list of cargo ids matching the empty port for the ship (local_goods_id), the list of cargo ids matching the ports around the empty port for the ship (near_goods_id), these two lists are used to record the cargo id data actively pushed after the shipowner app subscribes to the cargo notification. The number of cargo information of the empty port that the shipowner app has not read (local_unread_num) and the number of cargo information of the ports around the empty port that the shipowner app has not read (near_unread_num). These two data are used for shipowners to view their own ships and several new cargo sources that can be viewed after logging into the app. The above dynamic data are all generated by the successfully matched cargo data. All the above cargo ids have an expiration date, and their validity period comes from the effective deadline when the cargo source is released. When the deadline is reached, the redis system will automatically clear the corresponding cargo id data.
[0043] Combination Figure 4 As shown, 3. Goods source data: Each piece of goods source data published by the owner needs to be assigned a code goods_id. When the owner publishes a pallet, the pallet data will be stored in redis as a node data. The stored data includes: static data and dynamic data.
[0044] 2.1 Static data includes: cargo name, tonnage, departure time, departure port, etc.
[0045] Static data is stored in redis with each source of goods as a data group item and the source ID code as the change factor to form the key.
[0046] 2.2 Dynamic data includes: the list of ship IDs matching the source of goods at the port of departure (local_ship_id), the list of ship IDs matching the source of goods at ports around the port of departure (near_ship_id), these two lists are used to record the list of shipowner IDs that are actively pushed after the consignor app subscribes to the ship notification. The number of ship information at the port of departure that the consignor app has not read (local_unread_num) and the number of ship information at ports around the port of departure that the consignor app has not read (near_unread_num). These two data are used for the consignor to view his own cargo tray after logging into the app. There are several suitable new ships that can be viewed. The above dynamic data are all generated by the successfully matched ship data. All the above ship IDs have an expiration date, and their validity period comes from the effective empty ship time when the ship tray is released. When the deadline is reached, the redis system will automatically clear the corresponding ship ID data.
[0047] Specifically, a storage method for efficient and intelligent matching of cargo and ship in the present application includes:
[0048] Step 1) Load the configured port data into the port data area of redis when the system starts
[0049] Step 2) When the ship owner publishes an empty ship order (ship_id), first store the basic information of the ship order in the basic information in the redis ship data area (ship_id:xxxxx:base_data) and set the expiration time
[0050] Step 3) At the same time, you need to add the ship_id to the ship list in the redis port data area (area_id: zzzzz:ship_id:xxxxx)
[0051] Step 5) Take out the cargo source id list corresponding to the empty port (area_id) from the redis port data area (if the cargo owner has already published the cargo list), obtain the corresponding cargo source information from the redis cargo source data area through the cargo source id (goods_id), and match the information with the empty cargo list information one by one, including loading time, cargo volume and deadweight tonnage, loading and unloading port, ship type, navigation area, etc. If there is no match, ignore this goods_id cargo source data and continue to loop the matching process of the next cargo source id
[0052] Step 6) If the cargo requirements of both parties are met, indicating that the ship matches the source of goods, then add the goods_id of the source of goods to the local_goods_id list corresponding to the ship id in the redis ship data area, and record the matching data in the data table for later inspection
[0053] Step 7) If the empty ship order contains surrounding ports that can be emptied and loaded, the ship_id should also be added to the corresponding ship list of the ports surrounding the empty port in the redis port data area, and the ship should also be matched with the cargo information in the ports surrounding the empty port (refer to steps 5 and 6). The successfully matched cargo id is recorded in the near_goods_id list. This ensures that when the ship order is released, the ship id is included in the port data items of the empty port and the empty port, so as to facilitate the acquisition of the ship_id for quick matching when the subsequent cargo source is released.
[0054] Step 8) If message notification is required, after the match is successful, an asynchronous operation is triggered to notify the message system to send a match success notification to the shipowner
[0055] Step 9) When the shipowner cancels the order, first remove the ship_id in the list of ships in the empty port and surrounding empty ports in the port data area
[0056] Step 10) Obtain the list of cargo source IDs corresponding to the ship ID by associating the port ID, and clear the ship_id corresponding to the cargo source ID in the cargo source data area that contains the ship
[0057] Step 11) Obtain the list of available port IDs corresponding to the ship ID by associating the port ID. Repeat step 10 from the list of cargo source IDs in the available port list to clear the ship_id corresponding to the cargo source ID in the available port.
[0058] Step 12) When the owner releases the goods (goods_id), first store the basic information of the goods into the basic information in the redis source data area (goods_id:yyyyy:base_data), and set the expiration time
[0059] Step 13) At the same time, you need to add goods_id to the source id list in the redis port data area (area_id: zzzzz:goods_id:yyyyy)
[0060] Step 14) Take out the ship ID list corresponding to the departure port (area_id) from the redis port data area (if the ship owner has already published the ship order, like the ship order data published earlier), obtain the corresponding ship information from the redis ship data area through the ship ID (ship_id), and match the information with the cargo pallet one by one, including loading time, cargo volume and deadweight tonnage, loading and unloading ports, ship type, navigation area, etc. If there is no match, ignore this ship_id ship order data and continue to loop the matching process of the next ship ID
[0061] Step 15) If the cargo requirements of both parties are met, indicating that the cargo source matches the ship, the ship's ship_id is added to the local_ship_id list corresponding to the cargo source id in the redis cargo source data area, and the matching data is recorded in the data table for later inspection
[0062] Step 16) If the departure port includes surrounding ports, the goods_id should also be added to the corresponding source id list of the surrounding ports in the redis port data area, and the source of goods should also be matched with the ship information in the surrounding ports (refer to steps 14 and 15). The successfully matched ship id is recorded in the near_ship_id list. This ensures that when the cargo order is released, the port data area of the departure port and the surrounding ports contains the source id, so that the subsequent shipowner can obtain the goods_id for quick matching when releasing the ship order.
[0063] Step 17) If message notification is required, after the match is successful, an asynchronous operation is triggered to notify the message system to send a matching success notification to the owner.
[0064] Step 18) When the cargo owner cancels the cargo pallet, first remove the goods_id in the cargo source list of the origin port and surrounding ports in the port data area
[0065] Step 19) Obtain the ship id list corresponding to the cargo source id by associating the port id, and clear the goods_id corresponding to the ship id in the ship data area that contains the cargo source
[0066] Step 20) Obtain the list of surrounding port IDs corresponding to the cargo source ID by associating the port ID. Repeat step 19 for the ship ID list in the surrounding port list to clear the ship_id corresponding to the cargo source ID in the surrounding ports.
[0067] Step 21) After the shipowner publishes the order, he can directly obtain the matching cargo list in the ship data area by ship ID, without having to obtain it from the database, which is fast and efficient.
[0068] Step 22) After the cargo owner releases the cargo pallet, he can directly obtain the matching ship ID list in the cargo source data area through the cargo source ID.
[0069] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0070] The above is only a specific implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A storage method for efficient and intelligent matching of cargo and ships, based on high-speed cache Redis, characterized by: Includes: Step 1: Load port data into the port data area of redis; Step 2: When the vacant ship information is released, the vacant ship information is stored in the basic information in the redis ship data area and an expiration time is set; at the same time, the vacant ship ID is added to the ship list in the redis port data area; Step 3: Get the cargo source ID list corresponding to the empty port in the redis port data area, obtain the corresponding cargo source information from the redis cargo source data area through the cargo source ID, and match it with the empty port information one by one; Step 4: When the empty ship order information matches the cargo source information, add the cargo source ID to the list of cargo source IDs matching the empty ship port corresponding to the empty ship order ID in the redis ship data area; Step 5: When the empty ship order information is cancelled, the empty ship order ID is removed from the redis port data area; at the same time, the empty ship order ID is removed from the redis cargo data area; Step 6: When the pallet information is released, the pallet information is stored in the redis supply data area and an expiration time is set; At the same time, add the pallet ID to the source ID list in the redis port data area; Step 7: Get the ship ID list corresponding to the departure port in the redis port data area, obtain the corresponding ship information from the redis ship data area through the ship ID, and match it with the pallet information one by one; Step 8: When the cargo information matches the ship information, add the ship ID to the list of ship IDs that match the cargo source at the corresponding port of departure in the cargo source data area of Redis; Step 9: When the cargo pallet information is cancelled, the cargo pallet ID is removed from the cargo source list in the departure port and surrounding ports in the redis port data area; The port data includes: port name, surrounding port ID list, cargo source ID list and empty ship ID list; The empty ship order information includes: basic information, a list of cargo source IDs matching the empty ship port, and a list of cargo source IDs matching the empty ship port's surrounding ports. The basic information includes: loading time, cargo volume and deadweight, loading and unloading ports, ship type, and navigation area. The cargo pallet information includes: basic information, a list of ship IDs matching the cargo source at the port of departure, and a list of ship IDs matching the cargo source at ports surrounding the port of departure. The basic information includes: loading time, cargo volume and deadweight, loading and unloading ports, ship type, and navigation area; The step 3 further includes: the empty vessel information includes information of surrounding ports that can be emptied for loading, adding the empty vessel ID to the list of ships in the ports surrounding the empty port in the redis port data area, obtaining a list of cargo source IDs in the ports surrounding the empty port in the redis port data area, obtaining corresponding cargo source information from the redis cargo source data area according to the cargo source ID, and matching the empty vessel information one by one; The step 7 further includes: the port of departure in the pallet information includes surrounding ports, the pallet ID is added to the corresponding source ID list of the surrounding ports in the redis port data area, the ship ID list of the surrounding ports in the redis port data area is obtained, the ship information is obtained through the ship ID list, and it is matched with the pallet information one by one.
