| Line 1... |
Line 1... |
| 1 |
package com.smartdukaan.cron.scheduled;
|
1 |
package com.smartdukaan.cron.scheduled;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import com.smartdukaan.cron.migrations.RunOnceTasks;
|
| 4 |
import java.nio.file.Files;
|
4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 5 |
import java.nio.file.Paths;
|
5 |
import com.spice.profitmandi.dao.entity.fofo.ActivatedImei;
|
| 6 |
import java.time.LocalDate;
|
6 |
import com.spice.profitmandi.dao.model.ImeiActivationTimestampModel;
|
| 7 |
import java.time.LocalDateTime;
|
7 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
| 8 |
import java.time.format.DateTimeFormatter;
|
8 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 9 |
import java.util.ArrayList;
|
- |
|
| 10 |
import java.util.HashMap;
|
- |
|
| 11 |
import java.util.HashSet;
|
- |
|
| 12 |
import java.util.List;
|
- |
|
| 13 |
import java.util.Map;
|
9 |
import okhttp3.*;
|
| 14 |
import java.util.stream.Collectors;
|
- |
|
| 15 |
|
- |
|
| 16 |
import org.apache.logging.log4j.LogManager;
|
10 |
import org.apache.logging.log4j.LogManager;
|
| 17 |
import org.apache.logging.log4j.Logger;
|
11 |
import org.apache.logging.log4j.Logger;
|
| 18 |
import org.json.JSONObject;
|
12 |
import org.json.JSONObject;
|
| 19 |
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 20 |
import org.springframework.stereotype.Component;
|
14 |
import org.springframework.stereotype.Component;
|
| 21 |
import org.springframework.util.StringUtils;
|
15 |
import org.springframework.util.StringUtils;
|
| 22 |
|
16 |
|
| 23 |
import com.smartdukaan.cron.migrations.RunOnceTasks;
|
- |
|
| 24 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
- |
|
| 25 |
import com.spice.profitmandi.dao.entity.fofo.ActivatedImei;
|
- |
|
| 26 |
import com.spice.profitmandi.dao.model.VivoImeiAndActivationTimeStampModel;
|
- |
|
| 27 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
- |
|
| 28 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
- |
|
| 29 |
|
- |
|
| 30 |
import okhttp3.Cookie;
|
17 |
import java.io.IOException;
|
| 31 |
import okhttp3.CookieJar;
|
18 |
import java.nio.file.Files;
|
| 32 |
import okhttp3.FormBody;
|
19 |
import java.nio.file.Paths;
|
| 33 |
import okhttp3.HttpUrl;
|
20 |
import java.time.LocalDate;
|
| 34 |
import okhttp3.OkHttpClient;
|
21 |
import java.time.LocalDateTime;
|
| 35 |
import okhttp3.Request;
|
- |
|
| 36 |
import okhttp3.RequestBody;
|
22 |
import java.time.format.DateTimeFormatter;
|
| 37 |
import okhttp3.Response;
|
23 |
import java.util.*;
|
| 38 |
|
24 |
|
| 39 |
@Component
|
25 |
@Component
|
| 40 |
class VivoImeiActivationService {
|
26 |
class VivoImeiActivationService {
|
| 41 |
|
27 |
|
| 42 |
@Autowired
|
28 |
@Autowired
|
| Line 71... |
Line 57... |
| 71 |
|
57 |
|
| 72 |
String captchaBreak = this.getNewCaptcha(okHttpClient);
|
58 |
String captchaBreak = this.getNewCaptcha(okHttpClient);
|
| 73 |
|
59 |
|
| 74 |
LOGGER.info("Captcha code {}", captchaBreak);
|
60 |
LOGGER.info("Captcha code {}", captchaBreak);
|
| 75 |
|
61 |
|
| 76 |
List<VivoImeiAndActivationTimeStampModel> imeisActivationList = activatedImeiRepository
|
62 |
List<ImeiActivationTimestampModel> imeisActivationList = activatedImeiRepository
|
| 77 |
.selectVivoImeiAndActivationTimeStamp();
|
63 |
.selectImeiActivationByBrand("Vivo");
|
| 78 |
|
64 |
|
| 79 |
LOGGER.info("Complete list size is - {}", imeisActivationList.size());
|
65 |
LOGGER.info("Complete list size is - {}", imeisActivationList.size());
|
| 80 |
this.getImeiActivation(captchaBreak, okHttpClient, imeisActivationList);
|
66 |
this.getImeiActivation(captchaBreak, okHttpClient, imeisActivationList);
|
| 81 |
|
67 |
|
| 82 |
}
|
68 |
}
|
| Line 104... |
Line 90... |
| 104 |
|
90 |
|
| 105 |
return captchaBreak;
|
91 |
return captchaBreak;
|
| 106 |
}
|
92 |
}
|
| 107 |
|
93 |
|
| 108 |
public void getImeiActivation(String captchaBreak, OkHttpClient okHttpClient,
|
94 |
public void getImeiActivation(String captchaBreak, OkHttpClient okHttpClient,
|
| 109 |
List<VivoImeiAndActivationTimeStampModel> imeisActivationList) throws Exception {
|
95 |
List<ImeiActivationTimestampModel> imeisActivationList) throws Exception {
|
| 110 |
|
96 |
|
| 111 |
for (VivoImeiAndActivationTimeStampModel vivoImeiAndActivationTimeStampModel: new HashSet<>(imeisActivationList)) {
|
97 |
for (ImeiActivationTimestampModel vivoImeiAndActivationTimeStampModel : new HashSet<>(imeisActivationList)) {
|
| 112 |
String imei = vivoImeiAndActivationTimeStampModel.getSerialNumber();
|
98 |
String imei = vivoImeiAndActivationTimeStampModel.getSerialNumber();
|
| 113 |
RequestBody formBody = new FormBody.Builder().add("imei", imei).add("code", captchaBreak).build();
|
99 |
RequestBody formBody = new FormBody.Builder().add("imei", imei).add("code", captchaBreak).build();
|
| 114 |
|
100 |
|
| 115 |
Request request1 = new Request.Builder().url("https://www.vivo.com/in/support/checkCode").post(formBody)
|
101 |
Request request1 = new Request.Builder().url("https://www.vivo.com/in/support/checkCode").post(formBody)
|
| 116 |
.build();
|
102 |
.build();
|