| Line 62... |
Line 62... |
| 62 |
import com.spice.profitmandi.dao.entity.fofo.DebitNote;
|
62 |
import com.spice.profitmandi.dao.entity.fofo.DebitNote;
|
| 63 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
63 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
| 64 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
64 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 65 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
65 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 66 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
66 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
67 |
import com.spice.profitmandi.dao.entity.fofo.FofoStoreGeofence;
|
| 67 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
68 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 68 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
69 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 69 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
70 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 70 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrder;
|
71 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrder;
|
| 71 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
72 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| Line 101... |
Line 102... |
| 101 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
102 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 102 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
103 |
import com.spice.profitmandi.dao.repository.fofo.DebitNoteRepository;
|
| 103 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
104 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
| 104 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
105 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 105 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
106 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| - |
|
107 |
import com.spice.profitmandi.dao.repository.fofo.FofoStoreGeofenceRepository;
|
| 106 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
108 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 107 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
109 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
| 108 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
110 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| 109 |
import com.spice.profitmandi.dao.repository.fofo.PrebookingOrderRepository;
|
111 |
import com.spice.profitmandi.dao.repository.fofo.PrebookingOrderRepository;
|
| 110 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
112 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| Line 286... |
Line 288... |
| 286 |
private ScanRecordRepository scanRecordRepository;
|
288 |
private ScanRecordRepository scanRecordRepository;
|
| 287 |
|
289 |
|
| 288 |
@Autowired
|
290 |
@Autowired
|
| 289 |
private JavaMailSender mailSender;
|
291 |
private JavaMailSender mailSender;
|
| 290 |
|
292 |
|
| - |
|
293 |
@Autowired
|
| - |
|
294 |
private FofoStoreGeofenceRepository fofoStoreGeofenceRepository;
|
| - |
|
295 |
|
| 291 |
private static final String ACCOUNT_ID = "aZ6flHhrgPIEl18buHdPBdueEN4";
|
296 |
private static final String ACCOUNT_ID = "aZ6flHhrgPIEl18buHdPBdueEN4";
|
| 292 |
private static final String SECRET_KEY = "a7rsX5B4UNNfTTx1-IJ19qdH48BT4YvBKlQJg3n3_KKNe7WWych55g";
|
297 |
private static final String SECRET_KEY = "a7rsX5B4UNNfTTx1-IJ19qdH48BT4YvBKlQJg3n3_KKNe7WWych55g";
|
| 293 |
|
298 |
|
| 294 |
public void populateGrnTimestamp() {
|
299 |
public void populateGrnTimestamp() {
|
| 295 |
List<Purchase> allPurchases = purchaseRepository.selectAll();
|
300 |
List<Purchase> allPurchases = purchaseRepository.selectAll();
|
| Line 1082... |
Line 1087... |
| 1082 |
// throw new Exception();
|
1087 |
// throw new Exception();
|
| 1083 |
}
|
1088 |
}
|
| 1084 |
|
1089 |
|
| 1085 |
public void createGeofence() throws IOException, ProfitMandiBusinessException {
|
1090 |
public void createGeofence() throws IOException, ProfitMandiBusinessException {
|
| 1086 |
|
1091 |
|
| 1087 |
// List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
1092 |
List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
|
| 1088 |
// for (FofoStore fofoStore : fofoStores) {
|
1093 |
for (FofoStore fofoStore : fofoStores) {
|
| 1089 |
// if (fofoStore.getLatitude() != null && fofoStore.getLongitude() != null) {
|
1094 |
if (fofoStore.getLatitude() != null && fofoStore.getLongitude() != null) {
|
| 1090 |
// CustomRetailer customRetailer =
|
- |
|
| 1091 |
// retailerService.getFofoRetailer(fofoStore.getId());
|
1095 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoStore.getId());
|
| 1092 |
OkHttpClient client = new OkHttpClient();
|
1096 |
OkHttpClient client = new OkHttpClient();
|
| 1093 |
okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
|
1097 |
okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");
|
| 1094 |
JSONObject geofe = new JSONObject();
|
1098 |
JSONObject geofe = new JSONObject();
|
| 1095 |
JSONArray geofences = new JSONArray();
|
1099 |
JSONArray geofences = new JSONArray();
|
| 1096 |
JSONObject geometry = new JSONObject();
|
1100 |
JSONObject geometry = new JSONObject();
|
| 1097 |
JSONObject geo = new JSONObject();
|
1101 |
JSONObject geo = new JSONObject();
|
| 1098 |
JSONArray coordinates = new JSONArray();
|
1102 |
JSONArray coordinates = new JSONArray();
|
| 1099 |
ArrayList<Double> crds = new ArrayList<>();
|
1103 |
ArrayList<Double> crds = new ArrayList<>();
|
| 1100 |
// crds.add(Double.parseDouble(fofoStore.getLongitude()));
|
1104 |
crds.add(Double.parseDouble(fofoStore.getLongitude()));
|
| 1101 |
// crds.add(Double.parseDouble(fofoStore.getLatitude()));
|
1105 |
crds.add(Double.parseDouble(fofoStore.getLatitude()));
|
| 1102 |
crds.add(77.08596155373755);
|
1106 |
// crds.add(77.08596155373755);
|
| 1103 |
crds.add(28.64944201113976);
|
1107 |
// crds.add(28.64944201113976);
|
| 1104 |
// coordinates.put(fofoStore.getLongitude());
|
1108 |
// coordinates.put(fofoStore.getLongitude());
|
| 1105 |
// coordinates.put(fofoStore.getLatitude());
|
1109 |
// coordinates.put(fofoStore.getLatitude());
|
| 1106 |
geo.put("type", "Point");
|
1110 |
geo.put("type", "Point");
|
| 1107 |
geo.put("coordinates", crds);
|
1111 |
geo.put("coordinates", crds);
|
| 1108 |
geometry.put("geometry", geo);
|
1112 |
geometry.put("geometry", geo);
|
| 1109 |
JSONObject metadata = new JSONObject();
|
1113 |
JSONObject metadata = new JSONObject();
|
| 1110 |
// metadata.put("name", customRetailer.getBusinessName());
|
1114 |
// metadata.put("name", customRetailer.getBusinessName());
|
| 1111 |
// metadata.put("city", customRetailer.getAddress().getCity());
|
1115 |
// metadata.put("city", customRetailer.getAddress().getCity());
|
| 1112 |
metadata.put("name", "Test");
|
1116 |
metadata.put("name", "Test");
|
| 1113 |
geometry.put("metadata", metadata);
|
1117 |
geometry.put("metadata", metadata);
|
| 1114 |
geometry.put("radius", 500);
|
1118 |
geometry.put("radius", 500);
|
| 1115 |
|
1119 |
|
| 1116 |
geofences.put(geometry);
|
1120 |
geofences.put(geometry);
|
| 1117 |
geofe.put("geofences", geofences);
|
1121 |
geofe.put("geofences", geofences);
|
| 1118 |
okhttp3.RequestBody body = okhttp3.RequestBody.create(mediaType, geofe.toString());
|
1122 |
okhttp3.RequestBody body = okhttp3.RequestBody.create(mediaType, geofe.toString());
|
| 1119 |
String authString = "Basic "
|
1123 |
String authString = "Basic "
|
| 1120 |
+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
|
1124 |
+ Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
|
| 1121 |
|
1125 |
|
| 1122 |
Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences").post(body)
|
1126 |
Request request1 = new Request.Builder().url("https://v3.api.hypertrack.com/geofences").post(body)
|
| 1123 |
.addHeader("Authorization", authString).build();
|
1127 |
.addHeader("Authorization", authString).build();
|
| 1124 |
|
1128 |
|
| 1125 |
Response response = client.newCall(request1).execute();
|
1129 |
Response response = client.newCall(request1).execute();
|
| 1126 |
|
1130 |
|
| 1127 |
JSONArray ja = new JSONArray(response.body().string());
|
1131 |
JSONArray ja = new JSONArray(response.body().string());
|
| 1128 |
LOGGER.info("ja" + ja);
|
1132 |
LOGGER.info("ja" + ja);
|
| 1129 |
LOGGER.info("jalength" + ja.length());
|
1133 |
LOGGER.info("jalength" + ja.length());
|
| 1130 |
for (int i = 0; i < ja.length(); i++) {
|
1134 |
for (int i = 0; i < ja.length(); i++) {
|
| 1131 |
JSONObject c = ja.getJSONObject(i);
|
1135 |
JSONObject c = ja.getJSONObject(i);
|
| 1132 |
String geofenceId = c.getString("geofence_id");
|
1136 |
String geofenceId = c.getString("geofence_id");
|
| 1133 |
LOGGER.info("geofenceId" + geofenceId);
|
1137 |
LOGGER.info("geofenceId" + geofenceId);
|
| - |
|
1138 |
FofoStoreGeofence fsg = new FofoStoreGeofence();
|
| - |
|
1139 |
fsg.setFofoId(customRetailer.getPartnerId());
|
| - |
|
1140 |
fsg.setGeofenceId(geofenceId);
|
| - |
|
1141 |
fofoStoreGeofenceRepository.persist(fsg);
|
| - |
|
1142 |
}
|
| - |
|
1143 |
|
| - |
|
1144 |
}
|
| 1134 |
|
1145 |
|
| 1135 |
}
|
1146 |
}
|
| 1136 |
|
1147 |
|
| 1137 |
}
|
1148 |
}
|
| 1138 |
|
1149 |
|
| 1139 |
// }
|
- |
|
| 1140 |
|
- |
|
| 1141 |
// }
|
- |
|
| 1142 |
|
- |
|
| 1143 |
public void getAllGeofences() throws IOException, ProfitMandiBusinessException {
|
1150 |
public void getAllGeofences() throws IOException, ProfitMandiBusinessException {
|
| 1144 |
|
1151 |
|
| 1145 |
OkHttpClient client = new OkHttpClient();
|
1152 |
OkHttpClient client = new OkHttpClient();
|
| 1146 |
|
1153 |
|
| 1147 |
String authString = "Basic "
|
1154 |
String authString = "Basic "
|