| 23724 |
amit.gupta |
1 |
package com.smartdukaan.cron.monitored;
|
| 23723 |
amit.gupta |
2 |
|
| 23794 |
govind |
3 |
import java.io.IOException;
|
| 23723 |
amit.gupta |
4 |
import java.util.HashMap;
|
|
|
5 |
import java.util.Map;
|
|
|
6 |
|
| 23755 |
amit.gupta |
7 |
import org.apache.logging.log4j.LogManager;
|
|
|
8 |
import org.apache.logging.log4j.Logger;
|
| 23723 |
amit.gupta |
9 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23794 |
govind |
10 |
import org.springframework.beans.factory.annotation.Value;
|
| 23723 |
amit.gupta |
11 |
import org.springframework.stereotype.Component;
|
|
|
12 |
|
|
|
13 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 23794 |
govind |
14 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
15 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| 23723 |
amit.gupta |
16 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 23731 |
amit.gupta |
17 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 23794 |
govind |
18 |
import com.spice.profitmandi.service.recharge.RechargeService;
|
|
|
19 |
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
|
| 23723 |
amit.gupta |
20 |
|
|
|
21 |
@Component
|
|
|
22 |
public class NagiosMonitorTasks {
|
|
|
23 |
|
| 23755 |
amit.gupta |
24 |
private static final Logger log = LogManager.getLogger(NagiosMonitorTasks.class);
|
| 23723 |
amit.gupta |
25 |
|
| 23794 |
govind |
26 |
@Value("${think.walnut.digital.recharge.transaction.mobile.url}")
|
|
|
27 |
private String thinkWalnutDigitalRechargeTransactionMobileUrl;
|
|
|
28 |
|
|
|
29 |
@Value("${think.walnut.digital.recharge.transaction.dth.url}")
|
|
|
30 |
private String thinkWalnutDigitalRechargeTransactionDthUrl;
|
|
|
31 |
|
|
|
32 |
@Value("${think.walnut.digital.recharge.enquiry.url}")
|
|
|
33 |
private String thinkWalnutDigitalRechargeEnquiryUrl;
|
|
|
34 |
|
|
|
35 |
@Value("${think.walnut.digital.recharge.balance.url}")
|
|
|
36 |
private String thinkWalnutDigitalRechargeBalanceUrl;
|
|
|
37 |
|
|
|
38 |
@Value("${think.walnut.digital.recharge.username}")
|
|
|
39 |
private String thinkWalnutDigitalRechargeUserName;
|
|
|
40 |
|
|
|
41 |
@Value("${think.walnut.digital.recharge.password}")
|
|
|
42 |
private String thinkWalnutDigitalRechargePassword;
|
|
|
43 |
|
|
|
44 |
@Value("${think.walnut.digital.recharge.auth.key}")
|
|
|
45 |
private String thinkWalnutDigitalRechargeAuthKey;
|
|
|
46 |
|
| 23723 |
amit.gupta |
47 |
@Autowired
|
| 23794 |
govind |
48 |
private ThinkWalnutDigitalRechargeProviderService thinkWalnutDigitalRechargeProviderService;
|
| 24121 |
govind |
49 |
|
| 23794 |
govind |
50 |
@Autowired
|
| 23723 |
amit.gupta |
51 |
private RestClient restClient;
|
| 23794 |
govind |
52 |
|
|
|
53 |
@Autowired
|
|
|
54 |
ItemRepository itemRepository;
|
| 24121 |
govind |
55 |
|
| 23731 |
amit.gupta |
56 |
@Autowired
|
| 23794 |
govind |
57 |
private RechargeService rechargeService;
|
| 23723 |
amit.gupta |
58 |
|
| 23794 |
govind |
59 |
@Autowired
|
| 37395 |
amit |
60 |
private BalanceGauges balanceGauges;
|
| 23794 |
govind |
61 |
|
| 24121 |
govind |
62 |
|
| 23723 |
amit.gupta |
63 |
public void reportSmsCount() throws Throwable {
|
|
|
64 |
String htmlpage;
|
| 23794 |
govind |
65 |
int currentSmsCount = 0;
|
| 24879 |
govind |
66 |
String uri = "/MessagingGateway/GetSMSBalance";
|
| 23723 |
amit.gupta |
67 |
Map<String, String> params = new HashMap<>();
|
| 24879 |
govind |
68 |
params.put("Username", "srlsaholic");
|
|
|
69 |
params.put("Password", "sr18mar");
|
| 23723 |
amit.gupta |
70 |
String response = restClient.post(SchemeType.HTTP, "103.15.179.45", 8085, uri, params, new HashMap<>());
|
|
|
71 |
// System.out.println("response Html"+response);
|
|
|
72 |
if (response.length() > 0) {
|
| 24879 |
govind |
73 |
htmlpage = response.substring(response.indexOf("=")+1);
|
|
|
74 |
System.out.println(htmlpage);
|
| 24891 |
amit.gupta |
75 |
currentSmsCount = Integer.parseInt(htmlpage.trim());
|
| 23794 |
govind |
76 |
log.info("Got successfully parsed {}", currentSmsCount);
|
| 37395 |
amit |
77 |
balanceGauges.setSmsBalance(currentSmsCount);
|
| 24121 |
govind |
78 |
|
| 23723 |
amit.gupta |
79 |
}
|
| 24121 |
govind |
80 |
|
| 23723 |
amit.gupta |
81 |
}
|
| 24121 |
govind |
82 |
|
|
|
83 |
public void currentThinkWalnutBalace() throws ProfitMandiBusinessException, IOException {
|
| 23794 |
govind |
84 |
RechargeCredential thinkWalnutDigitalRechargeCredential = new RechargeCredential();
|
|
|
85 |
thinkWalnutDigitalRechargeCredential.setRechargeUrl(thinkWalnutDigitalRechargeBalanceUrl);
|
|
|
86 |
thinkWalnutDigitalRechargeCredential.setRechargeUserName(thinkWalnutDigitalRechargeUserName);
|
|
|
87 |
thinkWalnutDigitalRechargeCredential.setRechargePassword(thinkWalnutDigitalRechargePassword);
|
|
|
88 |
thinkWalnutDigitalRechargeCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| 24121 |
govind |
89 |
float thinkWalnutBalance = thinkWalnutDigitalRechargeProviderService
|
|
|
90 |
.doCheckBalanceRequest(thinkWalnutDigitalRechargeCredential);
|
|
|
91 |
log.info("ThinkWalnut Balance {}", thinkWalnutBalance);
|
| 37395 |
amit |
92 |
balanceGauges.setRechargeWalletBalance(thinkWalnutBalance);
|
| 24121 |
govind |
93 |
|
| 23794 |
govind |
94 |
}
|
| 23723 |
amit.gupta |
95 |
}
|