Multi-source strategy implementation method based on multi-mode service scene
By implementing multi-source strategy processing methods in multi-modal business scenarios, the problem of code redundancy is solved, data processing efficiency is improved, and data processing flow in multi-modal scenarios is simplified.
Patent Information
- Application Number
- CN202411468598.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-01-03
Smart Images

Figure CN119248237A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multi-source strategy, and in particular to a multi-source strategy implementation method based on a multi-modal business scenario. Background Art
[0002] With the digitalization process of various enterprises in the power industry, the smart construction site system has become the choice for enterprises to pursue digital highlights. In the personnel positioning system business, it is necessary to analyze the positioning of personnel and generate multiple warnings. If the code is written according to normal logic, there will be many redundant parts, which will affect the system quality and development efficiency.
[0003] In response to the multi-source data processing needs in this multimodal business scenario, it is urgent to develop an adaptive multi-source strategy processing system to solve this pain point. Summary of the invention In order to solve the above-mentioned problems, the present invention provides a method for implementing a multi-source strategy based on a multi-modal business scenario.
[0004] In a first aspect, the present invention provides a method for implementing a multi-source strategy based on a multimodal business scenario, which adopts the following technical solution: A method for implementing a multi-source strategy based on a multi-modal business scenario includes: Obtain business data and source policy information; Inherit and configure basic interfaces based on source policy information; Configure the container's policy registration information and write it into the policy dictionary; The policy execution method is called according to the business type to process the business data.
[0005] Furthermore, the obtaining of business data and source policy information includes respectively obtaining user information and product information as well as different policy type information.
[0006] Furthermore, the basic interface inheritance and configuration according to the source policy information includes realizing the basic interface and inheriting the basic parent class, and performing relevant configuration of the basic interface.
[0007] Furthermore, the related configuration of the basic interface includes configuring in the interface that inherits the basic interface, setting the unique type of the source policy mode: String TYPE = XXX; and completing the code according to the business and interface methods.
[0008] Furthermore, the policy registration information of the configuration container is written into the policy dictionary, including registering the source policy information in the container; then the policy factory obtains the actual policy according to the configuration and places it in the policy chain, and then writes the policy chain into the policy dictionary for query use.
[0009] Furthermore, registering the source policy information in the container includes registering the service family class implemented according to the basic interface into the container, including the class name and the policy type.
[0010] Furthermore, the policy factory obtains the actual policy according to the configuration and places it into the policy chain, and writes the policy chain into the policy dictionary, including obtaining different policy registration information in the policy factory and registering according to the different policy registration information. If the policy chain of this type is empty, a policy chain is initialized first and then stored. Finally, all policy chains are stored in the policy dictionary of the policy factory.
[0011] Furthermore, the policy execution method is called according to the business type to process the business data, including transmitting the business data to the downstream service for consumption, calling the entry method of the policy factory and finding a suitable policy chain according to the business type; and processing the business data according to the business logic of the actual scenario.
[0012] Furthermore, the entry method of the strategy factory is called and a suitable strategy chain is found according to the business type, including calling the strategy execution method doStrategy of the strategy factory after implementing the interface according to the business type of the business data, passing in the corresponding business data structure json in the self-implementation method and the strategy type type to be executed, and finding the strategy chain previously placed in the dictionary according to the type.
[0013] Furthermore, the business data is processed according to the business logic of the actual scenario, including matching a suitable strategy to process the business data according to a custom data structure in JSON.
[0014] In summary, the present invention has the following beneficial technical effects: When the present invention is directed to business processing in a multimodal scenario, the user can call the SDK of the multi-source strategy system or integrate the source code to conveniently and quickly process the data in this scenario, reduce the redundancy of program codes, and improve the efficiency of data processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a schematic diagram of a method for implementing a multi-source strategy in a multi-modal business scenario according to an embodiment of the present invention.
[0016] Figure 2 It is a schematic diagram of the core interface, class and data structure of an embodiment of the present invention. DETAILED DESCRIPTION
[0017] The present invention is further described in detail below in conjunction with the accompanying drawings.
[0018] Example 1 Reference Figure 1, a method for implementing a multi-source strategy based on a multi-modal service scenario in this embodiment includes: Obtain business data and source policy information; Inherit and configure basic interfaces based on source policy information; Configure the container's policy registration information and write it into the policy dictionary; Call the policy execution method to process business data according to the business type; The acquisition of business data and source policy information includes respectively acquiring user information and product information and different policy type information. The inheritance and configuration of the basic interface according to the source policy information includes implementing the basic interface and inheriting the basic parent class, and performing relevant configuration of the basic interface. The relevant configuration of the basic interface includes configuring in the interface that inherits the basic interface, setting the unique type of the source policy mode: String TYPE = XXX; completing the code according to the business and interface methods.
[0019] The configuration container's policy registration information is written into the policy dictionary, including registering the source policy information in the container; then the policy factory obtains the actual policy according to the configuration and places it in the policy chain, and then writes the policy chain into the policy dictionary for query use. The registration of the source policy information in the container includes registering the business family class implemented by the basic interface into the container, including the class name and policy type. The policy factory obtains the actual policy according to the configuration and places it in the policy chain, and writes the policy chain into the policy dictionary, including obtaining different policy registration information in the policy factory, registering according to different policy registration information, wherein, if the policy chain of this type is empty, a policy chain is initialized first and then stored, and finally all policy chains are stored in the policy dictionary of the policy factory. The calling of the policy execution method according to the business type to process the business data includes transmitting the business data to the service downstream for consumption, calling the entry method of the policy factory and finding a suitable policy chain according to the business type; processing the business data according to the business logic of the actual scenario. The entry method of the strategy factory is called and the appropriate strategy chain is found according to the business type, including calling the strategy execution method doStrategy of the strategy factory after implementing the interface according to the business type of the business data, passing in the corresponding business data structure json in the self-implementation method and the strategy type type to be executed, and finding the strategy chain previously put into the dictionary according to type. The business data is processed according to the business logic of the actual scenario, including matching the appropriate strategy according to the custom data structure in json to process the business data.
[0020] Specifically, In the code design stage: inherit and implement according to the basic interface provided by the system, inherit the basic parent class (see the third part of the work process); configure in the interface that inherits the basic interface, set the unique type of the source policy mode: String TYPE = XXX; finally, implement and write code for the interface method according to your own business.
[0021] In the early stage of system startup: implement the InitializingBean interface in the implementation class of the final source strategy. The code block in this method will run automatically after the system starts, and put the registration information of this strategy into the system container, such as class name and strategy type.
[0022] The policy factory has cooperated with the policy type TYPE field configured above to obtain and distinguish different source policies, and then obtain different policy registrations for registration; if the policy chain of this type is empty, a policy chain is initialized first (new List <basestrategy>list) and finally all policy chains are placed in the factory's own policy dictionary (Map <String, List <basestrategy>>strategyChainMap).
[0023] When the system is running: Business data is generated from various sources, such as proprietary business products, third-party data push, IoT edge data reporting, etc. In data services from different sources, after implementing the interface, the strategy execution method doStrategy of the strategy factory is called, and the corresponding business data structure json in the self-implementation method and the strategy type type to be executed are passed in. Then, the strategy chain previously put into the dictionary can be automatically found according to the type, and the appropriate strategy is matched according to the custom data structure in json to process the business data.
[0024] As a further embodiment, This embodiment provides a method for implementing a multi-source strategy based on a multi-modal service scenario, comprising the following steps: For an e-commerce platform, different marketing strategies need to be formulated according to different product types and user behaviors. For new users who buy electronic products, certain discounts can be given; for old users who buy daily necessities, points can be provided.
[0025] 1. Obtain business data and source policy information.
[0026] Business data may include user information (such as user ID, user type, purchase history, etc.) and product information (such as product ID, product type, price, etc.).
[0027] The source policy information may include different marketing policy types, such as discount policy, point policy, etc.
[0028] 2. Perform basic interface inheritance and configuration according to source policy information.
[0029] Define a basic interface MarketingStrategy, which includes an abstract method applyStrategy for applying marketing strategies.
[0030] Create different strategy classes, such as DiscountStrategy and PointsStrategy, that inherit from the MarketingStrategy base parent class.
[0031] In the DiscountStrategy class, set the unique type String TYPE = "DISCOUNT" and complete the discount calculation code according to the electronic product sales business and interface method.
[0032] In the PointsStrategy class, set the unique type String TYPE = "POINTS" and complete the code for point calculation based on the sales business of daily necessities and the interface method.
[0033] 3. Configure the container's policy registration information and write it into the policy dictionary.
[0034] Create a strategy container class StrategyContainer to register source strategy information. Register different strategy classes in the container, including the class name and strategy type.
[0035] When the application starts, different strategy classes are registered with the container.
[0036] Create a strategy factory class StrategyFactory, obtain the actual strategy according to the configuration and place it in the strategy chain, and then write the strategy chain into the strategy dictionary.
[0037] Call the policy execution method to process business data according to the business type When a user makes a purchase, the business data (user information and product information) is transmitted to the downstream service for consumption.
[0038] Call the entry method of the policy factory and find the appropriate policy chain according to the business type.
[0039] Process business data based on the business logic of the actual scenario. In this example, the business data is processed by matching the appropriate strategy based on the custom data structure in the user information and product information (such as user type, product type, etc.), that is, applying a discount or points strategy.
[0040] As a further embodiment, The pseudo code of a multi-source strategy implementation method based on a multi-modal business scenario is as follows: Setting parameters: - ( \beta ) : original data - ( \text{Preprocess}(\beta) ) : Preprocessing function, including edge computing and data cleaning - ( \text{Origin} = \text{Preprocess}(\beta) ) : source data after preprocessing - ( \text{StrategyFactory} ) : Strategy factory - ( \text{type} ) : strategy type - ( \text{strategyMap} ) : strategy dictionary - ( \text{chain} ) : process chain - ( \text{Result} = \text{Process}(\text{Origin}, \text{chain}) ) : Final business display data algorithm: 1. Input: original data ( \beta ) 2. Preprocessing: Perform preprocessing operations ( \text{Origin} \leftarrow \text{Preprocess}(\beta) ) 3. Acquisition strategy: The policy type ( \text{type} ) passed in based on the business call Get the processing chain from the policy dictionary ( \text{chain} \leftarrow \text{StrategyFactory.getStrategy}(\text{strategyMap}, \text{type}) ) 4. Data processing: Use the matched processing chain to process the source data ( \text{Result} \leftarrow \text{Process}(\text{Origin}, \text{chain}) ) 5. Output: Return the final business display data ( \text{Result} ) Pseudocode example: function processData(beta, type): / / Step 1: Processing raw data Origin = Preprocess(beta) / / Step 2: Get the corresponding policy chain based on the type TYPE passed in by the business code call chain = StrategyFactory.getStrategy(strategyMap, type) / / Step 3: Match the appropriate strategy according to the strategy chain to process the orgin data with business significance Result = Process(Origin, chain) / / Step 4: Return results return Result illustrate: - Preprocess: includes edge computing and data cleaning, and can implement different preprocessing logics according to specific needs.
[0041] - StrategyFactory: Responsible for matching and returning the appropriate processing chain from the strategy dictionary according to the strategy type.
[0042] - Process: Execute specific business logic, transform the source data according to the processing chain, and obtain the final result.
[0043] like Figure 2 Shown are the interfaces that need to be implemented and the inherited class descriptions.
[0044] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.< / basestrategy> < / basestrategy>
Claims
1. A method for implementing a multi-source strategy based on a multi-modal business scenario, characterized in that: include: Obtain business data and source policy information; Inherit and configure basic interfaces based on source policy information; Configure the container's policy registration information and write it into the policy dictionary; The policy execution method is called according to the business type to process the business data.
2. According to claim 1, a method for implementing a multi-source strategy in a multi-modal business scenario is characterized in that: The obtaining of business data and source policy information includes respectively obtaining user information and commodity information as well as different policy type information.
3. The method for implementing a multi-source strategy based on a multi-modal business scenario according to claim 2, characterized in that: The basic interface inheritance and configuration according to the source policy information includes realizing the basic interface and inheriting the basic parent class, and performing relevant configuration of the basic interface.
4. The method for implementing a multi-source strategy based on a multi-modal business scenario according to claim 3, characterized in that: The related configuration of the basic interface includes configuration in the interface that inherits the basic interface, setting the unique type of the source policy mode: String TYPE = XXX; and completing the code according to the business and interface methods.
5. The method for implementing a multi-source strategy based on a multi-modal business scenario according to claim 4, characterized in that: The configuration container's policy registration information is written into the policy dictionary, including registering source policy information in the container; then the policy factory obtains the actual policy according to the configuration and places it into the policy chain, and then writes the policy chain into the policy dictionary for query use.
6. The method for implementing a multi-source strategy based on a multi-modal business scenario according to claim 5, characterized in that: The registering of the source policy information in the container includes registering the service family class implemented according to the basic interface into the container, including the class name and the policy type.
7. The method for implementing a multi-source strategy based on a multi-modal business scenario according to claim 6, characterized in that: The policy factory obtains the actual policy according to the configuration and places it into the policy chain, and writes the policy chain into the policy dictionary, including obtaining different policy registration information in the policy factory and registering according to the different policy registration information. If the policy chain of this type is empty, a policy chain is initialized first and then stored. Finally, all policy chains are stored in the policy dictionary that comes with the policy factory.
8. The method for implementing a multi-source strategy based on a multi-modal business scenario according to claim 7, characterized in that: The policy execution method is called according to the business type to process the business data, including transmitting the business data to the downstream service for consumption, calling the entry method of the policy factory and finding the appropriate policy chain according to the business type; processing the business data according to the business logic of the actual scenario.
9. The method for implementing a multi-source strategy based on a multi-modal business scenario according to claim 8, characterized in that: The entry method of the strategy factory is called and the appropriate strategy chain is found according to the business type, including calling the strategy execution method doStrategy of the strategy factory after implementing the interface according to the business type of the business data, passing in the corresponding business data structure json in the self-implementation method and the strategy type type to be executed, and finding the strategy chain previously put into the dictionary according to the type.
10. A method for implementing a multi-source strategy based on a multi-modal business scenario according to claim 9, characterized in that: The business data is processed according to the business logic of the actual scenario, including matching the appropriate strategy to process the business data according to the customized data structure in JSON.
