Replace single get Google address API to Bulk get address API and Create Local cache for address
This commit is contained in:
parent
63d062c4a7
commit
e24269c2a5
8 changed files with 2781 additions and 2566 deletions
|
|
@ -112,7 +112,7 @@ console.log(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.contactService.dealerInfo(this.url == 'localhost:4200' ?'oneqlik.in':this.url ).subscribe(
|
this.contactService.dealerInfo(this.url == 'localhost:4200' ?'www.oneqlik.in':this.url ).subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.userData = data
|
this.userData = data
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import { map, take } from 'rxjs/operators';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ContactService {
|
export class ContactService {
|
||||||
totalTicketCount:BehaviorSubject<number> = new BehaviorSubject<number>(10);
|
totalTicketCount:BehaviorSubject<number> = new BehaviorSubject<number>(10);
|
||||||
|
latLongAddress={};
|
||||||
dev_url = environment.hostUrl;
|
dev_url = environment.hostUrl;
|
||||||
dev_url2= environment.hostUrl2
|
dev_url2= environment.hostUrl2
|
||||||
//dev_url = 'http://localhost:3000';
|
//dev_url = 'http://localhost:3000';
|
||||||
|
|
@ -1637,7 +1637,6 @@ addPOICol(poipayload){
|
||||||
.map(res => res.json());
|
.map(res => res.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setlanguage(payload){
|
setlanguage(payload){
|
||||||
return this.http.post(this.dev_url +'/users/set_user_setting',payload)
|
return this.http.post(this.dev_url +'/users/set_user_setting',payload)
|
||||||
.map(res => res.json());
|
.map(res => res.json());
|
||||||
|
|
@ -1650,9 +1649,20 @@ getLanguages(payload){
|
||||||
|
|
||||||
|
|
||||||
getAddressByApi(latlng){
|
getAddressByApi(latlng){
|
||||||
|
if(this.latLongAddress[latlng.long+'_'+latlng.lat]) {
|
||||||
|
console.log('get address for cache');
|
||||||
|
return Observable.of(this.latLongAddress[latlng.long+'_'+latlng.lat]);
|
||||||
|
} else {
|
||||||
return this.http.post(this.dev_url +'/googleAddress/getGoogleAddress',latlng)
|
return this.http.post(this.dev_url +'/googleAddress/getGoogleAddress',latlng)
|
||||||
.map(res => res.json());
|
.map(res => res.json());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
getAddressByApiBulk(latlng){
|
||||||
|
|
||||||
|
return this.http.post(this.dev_url +'/googleAddress/getGoogleAddressBulk',latlng)
|
||||||
|
.map(res => res.json());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -580,9 +580,24 @@ testTable() {
|
||||||
if (that.reportArr.length != 0) {
|
if (that.reportArr.length != 0) {
|
||||||
var j = 0;
|
var j = 0;
|
||||||
var finalArr = [];
|
var finalArr = [];
|
||||||
for (var i = 0; i < that.reportArr.length; i++) {
|
|
||||||
|
|
||||||
that.clocation_1(that.reportArr[i], function (err, succ) {
|
let latLongArray :any[] = [];
|
||||||
|
that.reportArr.forEach((deData)=>{
|
||||||
|
let latLng = {
|
||||||
|
lat: deData.startLat ? deData.startLat : 0,
|
||||||
|
long: deData.startLng ? deData.startLng : 0
|
||||||
|
}
|
||||||
|
latLongArray.push(latLng)
|
||||||
|
})
|
||||||
|
|
||||||
|
that.contactService.getAddressByApiBulk(latLongArray).subscribe(latLongAddress => {
|
||||||
|
that.reportArr.forEach((deData,index)=>{
|
||||||
|
let latLng = {
|
||||||
|
lat: deData.startLat ? deData.startLat : 0,
|
||||||
|
long: deData.startLng ? deData.startLng : 0
|
||||||
|
}
|
||||||
|
that.contactService.latLongAddress[latLng.long+'_'+latLng.lat] = latLongAddress[index];
|
||||||
|
that.clocation_1(deData, function (err, succ) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
j++;
|
j++;
|
||||||
|
|
@ -596,9 +611,12 @@ testTable() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
that.Load = false;
|
that.Load = false;
|
||||||
that.firstcall=true;
|
that.firstcall=true;
|
||||||
|
|
@ -793,13 +811,6 @@ tab:any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if () {
|
|
||||||
// latLng = {
|
|
||||||
// lat: 0,
|
|
||||||
// long: 0
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
outerThis.contactService.getAddressByApi(latLng).subscribe(res => {
|
outerThis.contactService.getAddressByApi(latLng).subscribe(res => {
|
||||||
if (res.message == "Address not found in databse") {
|
if (res.message == "Address not found in databse") {
|
||||||
var adata = {
|
var adata = {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ export class LocationComponent implements OnInit, OnDestroy {
|
||||||
isLastPosition = false;
|
isLastPosition = false;
|
||||||
toppingList: string[] = ['Extra cheese', 'Mushroom', 'Onion', 'Pepperoni', 'Sausage', 'Tomato'];
|
toppingList: string[] = ['Extra cheese', 'Mushroom', 'Onion', 'Pepperoni', 'Sausage', 'Tomato'];
|
||||||
imei
|
imei
|
||||||
|
latLongAddress={};
|
||||||
// private fuelComponent: SidemenuFuelComponent;
|
// private fuelComponent: SidemenuFuelComponent;
|
||||||
showLabels: boolean = true;
|
showLabels: boolean = true;
|
||||||
showAddress: boolean = false;
|
showAddress: boolean = false;
|
||||||
|
|
@ -1262,6 +1263,7 @@ export class LocationComponent implements OnInit, OnDestroy {
|
||||||
"lat": d_lat,
|
"lat": d_lat,
|
||||||
"long": d_lng
|
"long": d_lng
|
||||||
}
|
}
|
||||||
|
|
||||||
outerThis.contactService.getAddressByApi(latlng_1).subscribe(res => {
|
outerThis.contactService.getAddressByApi(latlng_1).subscribe(res => {
|
||||||
if (res.message == "Address not found in databse") {
|
if (res.message == "Address not found in databse") {
|
||||||
let geocoder = new google.maps.Geocoder();
|
let geocoder = new google.maps.Geocoder();
|
||||||
|
|
@ -1918,6 +1920,8 @@ export class LocationComponent implements OnInit, OnDestroy {
|
||||||
"lat": lat,
|
"lat": lat,
|
||||||
"long": long
|
"long": long
|
||||||
}
|
}
|
||||||
|
// on socket call
|
||||||
|
|
||||||
outerThis.contactService.getAddressByApi(latlng_1).subscribe(res => {
|
outerThis.contactService.getAddressByApi(latlng_1).subscribe(res => {
|
||||||
if (res.message == "Address not found in databse") {
|
if (res.message == "Address not found in databse") {
|
||||||
let geocoder = new google.maps.Geocoder();
|
let geocoder = new google.maps.Geocoder();
|
||||||
|
|
@ -3467,6 +3471,7 @@ zoomSet(){
|
||||||
|
|
||||||
this.ddid = dev.did
|
this.ddid = dev.did
|
||||||
this.contactService.getCurrentLocation(this.ddid, fromtime, totime).subscribe((data5) => {
|
this.contactService.getCurrentLocation(this.ddid, fromtime, totime).subscribe((data5) => {
|
||||||
|
|
||||||
this.latlongObjArr = data5;
|
this.latlongObjArr = data5;
|
||||||
// console.log("currlocdata=>",data5)
|
// console.log("currlocdata=>",data5)
|
||||||
// console.log(this.latlongObjArr)
|
// console.log(this.latlongObjArr)
|
||||||
|
|
@ -3786,9 +3791,14 @@ zoomSet(){
|
||||||
|
|
||||||
|
|
||||||
let cluster_arr = [];
|
let cluster_arr = [];
|
||||||
console.log(flightPath.getPath());
|
|
||||||
|
try {
|
||||||
|
|
||||||
this.path = flightPath.getPath();
|
this.path = flightPath.getPath();
|
||||||
|
} catch (error) {
|
||||||
|
console.log('flightPath.getPath()', error)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var cumulativeDistance = 0;
|
var cumulativeDistance = 0;
|
||||||
|
|
||||||
|
|
@ -3919,6 +3929,7 @@ zoomSet(){
|
||||||
"lat": lattitude,
|
"lat": lattitude,
|
||||||
"long": longitude
|
"long": longitude
|
||||||
}
|
}
|
||||||
|
|
||||||
outerThis.contactService.getAddressByApi(latlng_1).subscribe(res => {
|
outerThis.contactService.getAddressByApi(latlng_1).subscribe(res => {
|
||||||
|
|
||||||
if (res.message == "Address not found in databse") {
|
if (res.message == "Address not found in databse") {
|
||||||
|
|
@ -4041,7 +4052,8 @@ zoomSet(){
|
||||||
markersPasts['infowindow'] = new google.maps.InfoWindow({ content: content });
|
markersPasts['infowindow'] = new google.maps.InfoWindow({ content: content });
|
||||||
google.maps.event.addListener(markersPasts, 'click', function () {
|
google.maps.event.addListener(markersPasts, 'click', function () {
|
||||||
// console.log("inside info window function 1");
|
// console.log("inside info window function 1");
|
||||||
this['infowindow'].open(map, this); });
|
this['infowindow'].open(map, this);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4143,6 +4155,19 @@ zoomSet(){
|
||||||
if (data3) {
|
if (data3) {
|
||||||
clearInterval(countTime);
|
clearInterval(countTime);
|
||||||
}
|
}
|
||||||
|
let latLongArray : any[] = [];
|
||||||
|
data3.forEach((deData)=>{
|
||||||
|
latLongArray.push({
|
||||||
|
"long":deData.lng,
|
||||||
|
"lat":deData.lat
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
outerThis.contactService.getAddressByApiBulk(latLongArray).subscribe(latLongAddress => {
|
||||||
|
data3.forEach((deData,index)=>{
|
||||||
|
outerThis.contactService.latLongAddress[deData.lng+'_'+deData.lat] = latLongAddress[index];
|
||||||
|
})
|
||||||
|
|
||||||
// console.log('countercountercountercountercountercountercounter',counter,data3);
|
// console.log('countercountercountercountercountercountercounter',counter,data3);
|
||||||
var ft = new Date(fromtime);
|
var ft = new Date(fromtime);
|
||||||
|
|
@ -4165,7 +4190,6 @@ zoomSet(){
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showTable = true;
|
this.showTable = true;
|
||||||
|
|
||||||
this.latlongObjArr = data3;
|
this.latlongObjArr = data3;
|
||||||
this.flag = 'init';
|
this.flag = 'init';
|
||||||
initialize();
|
initialize();
|
||||||
|
|
@ -4173,7 +4197,13 @@ zoomSet(){
|
||||||
let cluster_arr = [];
|
let cluster_arr = [];
|
||||||
// console.log(flightPath.getPath());
|
// console.log(flightPath.getPath());
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
this.path = flightPath.getPath();
|
this.path = flightPath.getPath();
|
||||||
|
} catch (error) {
|
||||||
|
this.path = [];
|
||||||
|
console.log('flightPath.getPath()', error)
|
||||||
|
}
|
||||||
var cumulativeDistance = 0;
|
var cumulativeDistance = 0;
|
||||||
|
|
||||||
for (let i = this.latlongObjArr.length - 1; i > 0; i--) {
|
for (let i = this.latlongObjArr.length - 1; i > 0; i--) {
|
||||||
|
|
@ -4317,9 +4347,10 @@ zoomSet(){
|
||||||
"lat": lattitude,
|
"lat": lattitude,
|
||||||
"long": longitude
|
"long": longitude
|
||||||
}
|
}
|
||||||
outerThis.contactService.getAddressByApi(latlng_1).subscribe(res=>{
|
let addressRes = outerThis.contactService.latLongAddress[longitude+'_'+lattitude];
|
||||||
|
|
||||||
if(res.message == "Address not found in databse"){
|
|
||||||
|
if (!(addressRes && addressRes.address)) {
|
||||||
var geocoder = new google.maps.Geocoder();
|
var geocoder = new google.maps.Geocoder();
|
||||||
var latlng = new google.maps.LatLng(lattitude, longitude);
|
var latlng = new google.maps.LatLng(lattitude, longitude);
|
||||||
|
|
||||||
|
|
@ -4363,7 +4394,7 @@ zoomSet(){
|
||||||
var innerThis_1 = this;
|
var innerThis_1 = this;
|
||||||
|
|
||||||
this['infowindow'].open(map, innerThis_1);
|
this['infowindow'].open(map, innerThis_1);
|
||||||
var tempAdd = res.address ;
|
var tempAdd = addressRes.address;
|
||||||
// console.log('innerThis_1.contentAdd',tempAdd);
|
// console.log('innerThis_1.contentAdd',tempAdd);
|
||||||
var chkTmout = setTimeout(function () {
|
var chkTmout = setTimeout(function () {
|
||||||
var getAddressContent = document.getElementById('addressBinding');
|
var getAddressContent = document.getElementById('addressBinding');
|
||||||
|
|
@ -4374,7 +4405,7 @@ zoomSet(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4439,7 +4470,8 @@ zoomSet(){
|
||||||
markersPast['infowindow'] = new google.maps.InfoWindow({ content: content });
|
markersPast['infowindow'] = new google.maps.InfoWindow({ content: content });
|
||||||
google.maps.event.addListener(markersPast, 'click', function () {
|
google.maps.event.addListener(markersPast, 'click', function () {
|
||||||
// console.log("inside info window function 1");
|
// console.log("inside info window function 1");
|
||||||
this['infowindow'].open(map, this); });
|
this['infowindow'].open(map, this);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4539,6 +4571,7 @@ zoomSet(){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -4664,8 +4697,10 @@ zoomSet(){
|
||||||
position: new google.maps.LatLng(stop_locations[l][0], stop_locations[l][1]),
|
position: new google.maps.LatLng(stop_locations[l][0], stop_locations[l][1]),
|
||||||
map: outerThis.historyMap,
|
map: outerThis.historyMap,
|
||||||
// icon: pinImage,
|
// icon: pinImage,
|
||||||
label: {color: '#000', fontSize: '12px', fontWeight: '600',
|
label: {
|
||||||
text: index.toString()}
|
color: '#000', fontSize: '12px', fontWeight: '600',
|
||||||
|
text: index.toString()
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -7668,6 +7703,7 @@ var seconds = num % 60;
|
||||||
"lat": lat,
|
"lat": lat,
|
||||||
"long": lng
|
"long": lng
|
||||||
}
|
}
|
||||||
|
|
||||||
this.contactService.getAddressByApi(latlng_1).subscribe(res => {
|
this.contactService.getAddressByApi(latlng_1).subscribe(res => {
|
||||||
if (res.address != undefined) {
|
if (res.address != undefined) {
|
||||||
this.historyAdress = res.address;
|
this.historyAdress = res.address;
|
||||||
|
|
@ -8646,6 +8682,24 @@ for(let i = 0; i < this.reportArr.length; i++){
|
||||||
}
|
}
|
||||||
// console.log("RESSSS==>",this.reportArr);
|
// console.log("RESSSS==>",this.reportArr);
|
||||||
this.reportArr1 = this.reportArr
|
this.reportArr1 = this.reportArr
|
||||||
|
let latLongArray :any[] = [];
|
||||||
|
this.reportArr1.forEach((deData)=>{
|
||||||
|
latLongArray.push({
|
||||||
|
"long":deData.longDecimal ? deData.longDecimal : 0,
|
||||||
|
"lat":deData.latDecimal ? deData.latDecimal : 0
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
this.contactService.getAddressByApiBulk(latLongArray).subscribe(latLongAddress => {
|
||||||
|
this.reportArr1.forEach((deData,index)=>{
|
||||||
|
let latLng = {
|
||||||
|
lat: deData.latDecimal ? deData.latDecimal : 0,
|
||||||
|
long: deData.longDecimal ? deData.longDecimal : 0
|
||||||
|
}
|
||||||
|
this.contactService.latLongAddress[latLng.long+'_'+latLng.lat] = latLongAddress[index];
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (this.reportArr1.length != 0) {
|
if (this.reportArr1.length != 0) {
|
||||||
|
|
@ -8700,6 +8754,7 @@ this.reportArr1=this.reportArr
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}, err => {
|
}, err => {
|
||||||
this.Load = false;
|
this.Load = false;
|
||||||
|
|
||||||
|
|
@ -8725,14 +8780,6 @@ this.reportArr1=this.reportArr
|
||||||
long: latlngObj.longDecimal ? latlngObj.longDecimal : 0
|
long: latlngObj.longDecimal ? latlngObj.longDecimal : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if () {
|
|
||||||
// latLng = {
|
|
||||||
// lat: 0,
|
|
||||||
// long: 0
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
outerThis.contactService.getAddressByApi(latLng).subscribe(res => {
|
outerThis.contactService.getAddressByApi(latLng).subscribe(res => {
|
||||||
if (res.message == "Address not found in databse") {
|
if (res.message == "Address not found in databse") {
|
||||||
var adata = {
|
var adata = {
|
||||||
|
|
|
||||||
|
|
@ -325,9 +325,39 @@ export class CurrentPositionReportComponent implements OnInit {
|
||||||
if (that.reportArr.length != 0) {
|
if (that.reportArr.length != 0) {
|
||||||
var j = 0;
|
var j = 0;
|
||||||
that.finalArr = [];
|
that.finalArr = [];
|
||||||
for (var i = 0; i < that.reportArr.length; i++) {
|
|
||||||
if (that.reportArr[i]) {
|
|
||||||
|
|
||||||
|
let latLongArray :any[] = [];
|
||||||
|
that.reportArr.forEach((deData)=>{
|
||||||
|
|
||||||
|
let latLng = {
|
||||||
|
lat: "0",
|
||||||
|
long: "0"
|
||||||
|
};
|
||||||
|
|
||||||
|
latLng = {
|
||||||
|
long: deData.last_loc && deData.last_loc.coordinates && deData.last_loc.coordinates.length && deData.last_loc.coordinates[0] ? deData.last_loc.coordinates[0] : 0,
|
||||||
|
lat: deData.last_loc && deData.last_loc.coordinates && deData.last_loc.coordinates.length && deData.last_loc.coordinates[1] ? deData.last_loc.coordinates[1]: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
latLongArray.push(latLng)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
that.contactService.getAddressByApiBulk(latLongArray).subscribe(latLongAddress => {
|
||||||
|
|
||||||
|
|
||||||
|
for (var i = 0; i < that.reportArr.length; i++) {
|
||||||
|
|
||||||
|
if (that.reportArr[i]) {
|
||||||
|
let latLng = {
|
||||||
|
lat: "0",
|
||||||
|
long: "0"
|
||||||
|
};
|
||||||
|
latLng = {
|
||||||
|
long: that.reportArr[i].last_loc && that.reportArr[i].last_loc.coordinates && that.reportArr[i].last_loc.coordinates.length && that.reportArr[i].last_loc.coordinates[0] ? that.reportArr[i].last_loc.coordinates[0] : 0,
|
||||||
|
lat: that.reportArr[i].last_loc && that.reportArr[i].last_loc.coordinates && that.reportArr[i].last_loc.coordinates.length && that.reportArr[i].last_loc.coordinates[1] ? that.reportArr[i].last_loc.coordinates[1]: 0
|
||||||
|
}
|
||||||
|
that.contactService.latLongAddress[latLng.long+'_'+latLng.lat] = latLongAddress[i];
|
||||||
if (that.reportArr[i].status_updated_at == undefined) {
|
if (that.reportArr[i].status_updated_at == undefined) {
|
||||||
let dev_status_1 = that.reportArr[i].status ? that.reportArr[i].status : "Not available";
|
let dev_status_1 = that.reportArr[i].status ? that.reportArr[i].status : "Not available";
|
||||||
that.reportArr[i].status = dev_status_1;
|
that.reportArr[i].status = dev_status_1;
|
||||||
|
|
@ -401,6 +431,9 @@ export class CurrentPositionReportComponent implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
that.Load = false;
|
that.Load = false;
|
||||||
that.firstcall = true;
|
that.firstcall = true;
|
||||||
|
|
|
||||||
|
|
@ -210,31 +210,45 @@ export class DayWiseReportComponent implements OnInit {
|
||||||
that.reportArr = [];
|
that.reportArr = [];
|
||||||
that.reportArr= resp ;
|
that.reportArr= resp ;
|
||||||
if (that.reportArr.length != 0) {
|
if (that.reportArr.length != 0) {
|
||||||
console.log(that.reportArr);
|
|
||||||
var j = 0;
|
var j = 0;
|
||||||
that.finalArr = [];
|
that.finalArr = [];
|
||||||
|
|
||||||
|
let latLongArray :any[] = [];
|
||||||
|
that.reportArr.forEach((deData)=>{
|
||||||
|
let latLng = {
|
||||||
|
lat: deData.start_location ? deData.start_location.lat ? deData.start_location.lat : 0:0,
|
||||||
|
long: deData.start_location ? deData.start_location.long ? deData.start_location.long : 0:0
|
||||||
|
}
|
||||||
|
latLongArray.push(latLng)
|
||||||
|
let end_latLng = {
|
||||||
|
lat: deData.end_location ? deData.end_location.lat ? deData.end_location.lat : 0:0,
|
||||||
|
long: deData.end_location ? deData.end_location.long ? deData.end_location.long : 0:0
|
||||||
|
}
|
||||||
|
latLongArray.push(end_latLng)
|
||||||
|
})
|
||||||
|
|
||||||
|
that.contactService.getAddressByApiBulk(latLongArray).subscribe(latLongAddress => {
|
||||||
|
let indexCounter = 0;
|
||||||
for (var i = 0; i < that.reportArr.length; i++) {
|
for (var i = 0; i < that.reportArr.length; i++) {
|
||||||
|
let latLng = {
|
||||||
// if(that.reportArr[i].distanceVariation){
|
lat: that.reportArr[i].start_location ? that.reportArr[i].start_location.lat ? that.reportArr[i].start_location.lat : 0:0,
|
||||||
// console.log("IN");
|
long: that.reportArr[i].start_location ? that.reportArr[i].start_location.long ? that.reportArr[i].start_location.long : 0:0
|
||||||
|
}
|
||||||
// if(that.reportArr[i].distanceVariation[0]=="+"){
|
that.contactService.latLongAddress[latLng.long+'_'+latLng.lat] = latLongAddress[indexCounter];
|
||||||
// that.reportArr[i]['Distance(Kms)']=that.reportArr[i]['Distance(Kms)']+(that.reportArr[i]['Distance(Kms)']/100)*Number(that.reportArr[i].distanceVariation.substring(1))
|
indexCounter++;
|
||||||
// console.log("IN",(that.reportArr[i]['Distance(Kms)']/100)*Number(that.reportArr[i].distanceVariation.substring(1)));
|
let end_latLng = {
|
||||||
// }else{
|
lat: that.reportArr[i].end_location ? that.reportArr[i].end_location.lat ? that.reportArr[i].end_location.lat : 0:0,
|
||||||
|
long: that.reportArr[i].end_location ? that.reportArr[i].end_location.long ? that.reportArr[i].end_location.long : 0:0
|
||||||
// that.reportArr[i]['Distance(Kms)']=that.reportArr[i]['Distance(Kms)']-(that.reportArr[i]['Distance(Kms)']/100)*Number(that.reportArr[i].distanceVariation.substring(1))
|
}
|
||||||
// console.log("IN-",that.reportArr[i]['Distance(Kms)']);
|
that.contactService.latLongAddress[end_latLng.long+'_'+end_latLng.lat] = latLongAddress[indexCounter];
|
||||||
// }
|
console.log('indexCounter++',indexCounter,i)
|
||||||
// }
|
indexCounter++;
|
||||||
|
|
||||||
console.log(that.reportArr[i]['Idle Time'],that.reportArr[i]['Moving Time'],that.reportArr[i]['Stoppage Time'],that.reportArr[i]['Idle Time']);
|
|
||||||
|
|
||||||
if((that.reportArr[i]['Idle Time']+that.reportArr[i]['Stoppage Time']+that.reportArr[i]['Moving Time'])<24){
|
if((that.reportArr[i]['Idle Time']+that.reportArr[i]['Stoppage Time']+that.reportArr[i]['Moving Time'])<24){
|
||||||
that.reportArr[i].outOfReach=(24-(that.reportArr[i]['Idle Time']+that.reportArr[i]['Stoppage Time']+that.reportArr[i]['Moving Time'])).toFixed(2)
|
that.reportArr[i].outOfReach=(24-(that.reportArr[i]['Idle Time']+that.reportArr[i]['Stoppage Time']+that.reportArr[i]['Moving Time'])).toFixed(2)
|
||||||
}else{
|
}else{
|
||||||
that.reportArr[i].outOfReach=0.0
|
that.reportArr[i].outOfReach=0.0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
that.clocation_1(that.reportArr[i], function (err, succ) {
|
that.clocation_1(that.reportArr[i], function (err, succ) {
|
||||||
|
|
@ -277,7 +291,12 @@ export class DayWiseReportComponent implements OnInit {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log("HDH",that.reportArr)
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
that.Load = false;
|
that.Load = false;
|
||||||
callback({ data: [] });
|
callback({ data: [] });
|
||||||
|
|
|
||||||
|
|
@ -325,10 +325,40 @@ export class DisatanceReportComponent implements OnInit {
|
||||||
if (that.reportArr.length != 0) {
|
if (that.reportArr.length != 0) {
|
||||||
var j = 0;
|
var j = 0;
|
||||||
that.finalArr = [];
|
that.finalArr = [];
|
||||||
for (var i = 0; i < that.reportArr.length; i++) {
|
|
||||||
if (that.reportArr[i]){
|
|
||||||
|
|
||||||
that.clocation_1(that.reportArr[i], function (err, succ) {
|
let latLongArray :any[] = [];
|
||||||
|
that.reportArr.forEach((deData)=>{
|
||||||
|
let latLng = {
|
||||||
|
lat: deData.start_location ? deData.start_location.lat ? deData.start_location.lat : 0:0,
|
||||||
|
long: deData.start_location ? deData.start_location.long ? deData.start_location.long : 0:0
|
||||||
|
}
|
||||||
|
latLongArray.push(latLng)
|
||||||
|
let end_latLng = {
|
||||||
|
lat: deData.end_location ? deData.end_location.lat ? deData.end_location.lat : 0:0,
|
||||||
|
long: deData.end_location ? deData.end_location.long ? deData.end_location.long : 0:0
|
||||||
|
}
|
||||||
|
latLongArray.push(end_latLng)
|
||||||
|
})
|
||||||
|
|
||||||
|
that.contactService.getAddressByApiBulk(latLongArray).subscribe(latLongAddress => {
|
||||||
|
let indexCounter = 0;
|
||||||
|
that.reportArr.forEach((deData,index)=>{
|
||||||
|
let latLng = {
|
||||||
|
lat: deData.start_location ? deData.start_location.lat ? deData.start_location.lat : 0:0,
|
||||||
|
long: deData.start_location ? deData.start_location.long ? deData.start_location.long : 0:0
|
||||||
|
}
|
||||||
|
that.contactService.latLongAddress[latLng.long+'_'+latLng.lat] = latLongAddress[indexCounter];
|
||||||
|
indexCounter++;
|
||||||
|
let end_latLng = {
|
||||||
|
lat: deData.end_location ? deData.end_location.lat ? deData.end_location.lat : 0:0,
|
||||||
|
long: deData.end_location ? deData.end_location.long ? deData.end_location.long : 0:0
|
||||||
|
}
|
||||||
|
that.contactService.latLongAddress[end_latLng.long+'_'+end_latLng.lat] = latLongAddress[indexCounter];
|
||||||
|
indexCounter++;
|
||||||
|
if(deData) {
|
||||||
|
|
||||||
|
|
||||||
|
that.clocation_1(deData, function (err, succ) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
j++;
|
j++;
|
||||||
|
|
@ -346,11 +376,13 @@ export class DisatanceReportComponent implements OnInit {
|
||||||
} else {
|
} else {
|
||||||
that.Load = false;
|
that.Load = false;
|
||||||
callback({ data: [] });
|
callback({ data: [] });
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
that.Load = false;
|
that.Load = false;
|
||||||
that.firstcall = true;
|
that.firstcall = true;
|
||||||
|
|
|
||||||
|
|
@ -443,9 +443,64 @@ testTable() {
|
||||||
if (that.summary.length != 0) {
|
if (that.summary.length != 0) {
|
||||||
var j = 0;
|
var j = 0;
|
||||||
that.finalArr = [];
|
that.finalArr = [];
|
||||||
for (var i = 0; i < that.summary.length; i++) {
|
|
||||||
|
|
||||||
that.clocation_1(that.summary[i], function (err, succ) {
|
let latLongArray :any[] = [];
|
||||||
|
that.summary.forEach((deData)=>{
|
||||||
|
let latLng = {lat:0,
|
||||||
|
long:0};
|
||||||
|
let end_latLng = {lat:0,
|
||||||
|
long:0};
|
||||||
|
if (deData.start_location) {
|
||||||
|
latLng = {
|
||||||
|
lat: deData.start_location.lat ? deData.start_location.lat : 0,
|
||||||
|
long: deData.start_location.long ? deData.start_location.long : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (deData.today_start_location) {
|
||||||
|
latLng = {
|
||||||
|
lat: deData.today_start_location.lat ? deData.today_start_location.lat : 0,
|
||||||
|
long: deData.today_start_location.long ? deData.today_start_location.long : 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deData.today_start_location = deData.start_location;
|
||||||
|
}
|
||||||
|
latLongArray.push(latLng)
|
||||||
|
if (deData.last_location) {
|
||||||
|
end_latLng = {
|
||||||
|
lat: deData.last_location.lat ? deData.last_location.lat : 0,
|
||||||
|
long: deData.last_location.long ? deData.last_location.long : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (deData.end_location) {
|
||||||
|
end_latLng = {
|
||||||
|
lat: deData.end_location.lat ? deData.end_location.lat : 0,
|
||||||
|
long: deData.end_location.long ? deData.end_location.long : 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deData.end_location = deData.last_location;
|
||||||
|
}
|
||||||
|
latLongArray.push(end_latLng)
|
||||||
|
})
|
||||||
|
|
||||||
|
that.contactService.getAddressByApiBulk(latLongArray).subscribe(latLongAddress => {
|
||||||
|
let indexCounter = 0;
|
||||||
|
that.summary.forEach((deData,index)=>{
|
||||||
|
let latLng = {
|
||||||
|
lat: deData.today_start_location ? deData.today_start_location.lat ? deData.today_start_location.lat : 0:0,
|
||||||
|
long: deData.today_start_location ? deData.today_start_location.long ? deData.today_start_location.long : 0:0
|
||||||
|
}
|
||||||
|
that.contactService.latLongAddress[latLng.long+'_'+latLng.lat] = latLongAddress[indexCounter];
|
||||||
|
indexCounter++;
|
||||||
|
let end_latLng = {
|
||||||
|
lat: deData.end_location ? deData.end_location.lat ? deData.end_location.lat : 0:0,
|
||||||
|
long: deData.end_location ? deData.end_location.long ? deData.end_location.long : 0:0
|
||||||
|
}
|
||||||
|
that.contactService.latLongAddress[end_latLng.long+'_'+end_latLng.lat] = latLongAddress[indexCounter];
|
||||||
|
indexCounter++;
|
||||||
|
if(deData) {
|
||||||
|
|
||||||
|
//location code
|
||||||
|
that.clocation_1(deData, function (err, succ) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
j++;
|
j++;
|
||||||
|
|
@ -470,8 +525,16 @@ testTable() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
that.Load = false;
|
||||||
|
callback({ data: [] });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
that.Load = false;
|
that.Load = false;
|
||||||
callback({ data: [] });
|
callback({ data: [] });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue