The first way is to make use of caching. The commissionMerchantsBean is the parameter object passed in

           // The change should not take effect until next month
            // Query the tST_commission_merchants table based on merchants_id to obtain import_partner_employee_id
            CommissionMerchantsBean merchantsBean = commissionDaoC.getCommissionMerchants(commissionMerchantsBean);
            // Get the effective time in the cache
            String effectTimeImport = RedisUtils.getKey("effectTimeImport:" + commissionMerchants.getCommission_merchants_id());
            String effectTimeRelation = RedisUtils.getKey("effectTimeRelation:" + commissionMerchants.getCommission_merchants_id());
            if(tst.project.utils.StringUtils.isEmpty(effectTimeImport)){
                // If null, set cache
                RedisUtils.setKey("effectTimeImport:" + commissionMerchants.getCommission_merchants_id(),String.valueOf(TimeUtils.dateToStr(nextMonthStartTimes,"yyyy-MM")));
            }
            // Retrieve
            String effectTimeImport2 = RedisUtils.getKey("effectTimeImport:" + commissionMerchants.getCommission_merchants_id());
			// If the effective date of the import is not equal to the current month, set the imported import_partner_employee_id to the original data in the library
            if(effectTimeImport2.compareTo(TimeUtils.dateToStr(new Date(),"yyyy-MM")) != 0) {// If it is not empty and the date in the cache is several months ago, the next month will be the effective date
                RedisUtils.setKey("effectTimeImport:" + commissionMerchants.getCommission_merchants_id(),String.valueOf(TimeUtils.dateToStr(nextMonthStartTimes,"yyyy-MM")));
                // Set the employee ID of the partner to the original data
                String importPartnerEmployeeId = merchantsBean.getImport_partner_employee_id();
                commissionMerchantsBean.setImport_partner_employee_id(importPartnerEmployeeId);
            }
            if(tst.project.utils.StringUtils.isEmpty(effectTimeRelation)){
                // If null, set cache
                RedisUtils.setKey("effectTimeRelation:" + commissionMerchants.getCommission_merchants_id(),String.valueOf(TimeUtils.dateToStr(nextMonthStartTimes,"yyyy-MM")));
            }
            // Retrieve
            String effectTimeRelation2 = RedisUtils.getKey("effectTimeRelation:" + commissionMerchants.getCommission_merchants_id());
			// If the effective date of the association is not equal to the current month, set the passed relation_partner_employee_id to the original data in the database
			if(effectTimeRelation2.compareTo(TimeUtils.dateToStr(new Date(),"yyyy-MM")) != 0) {// If it is not empty and the date in the cache is several months ago, the next month will be the effective date
                RedisUtils.setKey("effectTimeRelation:" + commissionMerchants.getCommission_merchants_id(),String.valueOf(TimeUtils.dateToStr(nextMonthStartTimes,"yyyy-MM")));
                // Set the employee ID of the associated partner to the original one
                String relationPartnerEmployeeId = merchantsBean.getRelation_partner_employee_id();
                commissionMerchantsBean.setRelation_partner_employee_id(relationPartnerEmployeeId);
            }
            // Set the effective time to next month
            int num=commissionDaoC.updateCommissionMerchants(commissionMerchantsBean);
            if(num<=0) {throw new AppException("Update failed!");
            }
Copy the code

Second: you can use timed tasks

Third: you can use information queues