Rev 37395 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.smartdukaan.cron.monitored;import java.io.IOException;import java.util.HashMap;import java.util.Map;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.stereotype.Component;import com.spice.profitmandi.common.enumuration.SchemeType;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.RechargeCredential;import com.spice.profitmandi.common.web.client.RestClient;import com.spice.profitmandi.dao.repository.catalog.ItemRepository;import com.spice.profitmandi.service.recharge.RechargeService;import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;@Component/*** Reads the two prepaid balances -- SMS credits and the ThinkWalnut recharge wallet --* and pushes them into {@link BalanceGauges}.** ⚠ NOTHING CALLS THIS. There is no @Scheduled method and no other caller anywhere in* the codebase, which is why both gauges read -1 ("not read yet") on every scrape. The* micrometer bridge works; the trigger was never written. Either give it a @Scheduled* entry in ScheduledSkeleton or delete this and its gauges -- do not leave it half-wired.** Formerly NagiosMonitorTasks: the Nagios server and every NRPE daemon are gone, so the* name described a transport that no longer exists.*/public class BalanceMonitorTasks {private static final Logger log = LogManager.getLogger(BalanceMonitorTasks.class);@Value("${think.walnut.digital.recharge.transaction.mobile.url}")private String thinkWalnutDigitalRechargeTransactionMobileUrl;@Value("${think.walnut.digital.recharge.transaction.dth.url}")private String thinkWalnutDigitalRechargeTransactionDthUrl;@Value("${think.walnut.digital.recharge.enquiry.url}")private String thinkWalnutDigitalRechargeEnquiryUrl;@Value("${think.walnut.digital.recharge.balance.url}")private String thinkWalnutDigitalRechargeBalanceUrl;@Value("${think.walnut.digital.recharge.username}")private String thinkWalnutDigitalRechargeUserName;@Value("${think.walnut.digital.recharge.password}")private String thinkWalnutDigitalRechargePassword;@Value("${think.walnut.digital.recharge.auth.key}")private String thinkWalnutDigitalRechargeAuthKey;@Autowiredprivate ThinkWalnutDigitalRechargeProviderService thinkWalnutDigitalRechargeProviderService;@Autowiredprivate RestClient restClient;@AutowiredItemRepository itemRepository;@Autowiredprivate RechargeService rechargeService;@Autowiredprivate BalanceGauges balanceGauges;public void reportSmsCount() throws Throwable {String htmlpage;int currentSmsCount = 0;String uri = "/MessagingGateway/GetSMSBalance";Map<String, String> params = new HashMap<>();params.put("Username", "srlsaholic");params.put("Password", "sr18mar");String response = restClient.post(SchemeType.HTTP, "103.15.179.45", 8085, uri, params, new HashMap<>());// System.out.println("response Html"+response);if (response.length() > 0) {htmlpage = response.substring(response.indexOf("=")+1);System.out.println(htmlpage);currentSmsCount = Integer.parseInt(htmlpage.trim());log.info("Got successfully parsed {}", currentSmsCount);balanceGauges.setSmsBalance(currentSmsCount);}}public void currentThinkWalnutBalace() throws ProfitMandiBusinessException, IOException {RechargeCredential thinkWalnutDigitalRechargeCredential = new RechargeCredential();thinkWalnutDigitalRechargeCredential.setRechargeUrl(thinkWalnutDigitalRechargeBalanceUrl);thinkWalnutDigitalRechargeCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);thinkWalnutDigitalRechargeCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);thinkWalnutDigitalRechargeCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);float thinkWalnutBalance = thinkWalnutDigitalRechargeProviderService.doCheckBalanceRequest(thinkWalnutDigitalRechargeCredential);log.info("ThinkWalnut Balance {}", thinkWalnutBalance);balanceGauges.setRechargeWalletBalance(thinkWalnutBalance);}}