diff --git a/README.md b/README.md index ac800c8..8177a70 100644 --- a/README.md +++ b/README.md @@ -10,25 +10,22 @@ > >2. ORGANIZAÇÃO DO PROJETO > ->>2.1. Fluxograma +>>2.1. Visão Geral +>> +>>2.2. Fluxograma > >3. SOFTWARE > ->>3.1. GOOGLE CLOUD +>>3.1. GOOGLE CLOUD >> >>>3.1.1. Google API >>> >>>>3.1.1.1. Directions API ->>>>> ->>>>>3.1.1.1.1. Visão Geral ->>>>> +>>>> >>>>3.1.1.2. Distance Matrix API >>>> ->>>>>3.1.1.2.1. Visão Geral >>>> >>>>3.1.1.3. Compute Engine API ->>>>> ->>>>>3.1.1.3.1. Visão Geral >>> >>>3.1.2. Instâncias Virtuais >>> @@ -42,9 +39,48 @@ >>>> >>>>3.1.3.2 Instalação e Implementação >>> ->> >>3.2. FRONTEND >> +>>>3.2.1. Componentes +>>>> +>>>>3.2.1.1. Login +>>>>> +>>>>>3.2.1.1.1. CanActivate +>>>>> +>>>>>3.2.1.1.2. HttpClient +>>>> +>>>>3.2.1.2. Home +>>>> +>>>>3.2.1.3. Dashboard +>>>>> +>>>>>3.2.1.3.1. Contador de Clientes e Visitantes +>>>>> +>>>>>3.2.1.3.2. Registro de Pacotes +>>>>> +>>>>>3.2.1.3.3. Bounce Rate +>>>> +>>>>3.2.1.4. Users +>>>> +>>>>3.2.1.5. Pacotes +>>>>> +>>>>>3.2.1.5.1. Recent Quote +>>>>> +>>>>>3.2.1.5.2. Register Quote +>>>>> +>>>>>3.2.1.5.3. Tracking Package +>>> +>>>3.2.2. Services +>>>> +>>>>3.2.2.1. Login Service +>>>> +>>>>3.2.2.2. Quote Service +>>> +>>>3.2.3. Segurança (A analisar) +>>>> +>>>>3.2.3.1. Dados do Login +>>>> +>>>>3.2.3.2. Encriptação dos Dados +>> >>3.3. BACKEND >>> >>>3.3.1. Spring Boot @@ -73,7 +109,7 @@ ## 1 - RESUMO -
+
1.1 - Da Licença, Disponibilidade e Finalidade ####      Esse projeto foi desenvolvido pelo grupo Roxo da Turma Java Noturno de 2022, composto por Bruno Roberto, Cristian Schauffert, Kalil Fakhouri e Mateus Felipe com a mentoria do professor Oliota, visando apenas a demonstração dos conhecimentos técnicos adquiridos durante o curso e a apresentação da etapa final à empresas. @@ -86,7 +122,7 @@
-
+
1.2 - Das Tecnologias Utilizadas ####      Durante o curso foi utilizado diversas tecnologias, métodos ágeis e ferramentas de desenvolvimento tais como: @@ -112,3 +148,36 @@ > #### Metodologia: >> * ##### kaka-vscode Trello - Kanban +
+

+ +# 2 - ORGANIZAÇÃO DO PROJETO + +
+2.1 - Visão Geral + +####      + +
+ +
+2.2 - Fluxograma + + + +
+ +

+ +# 3 - SOFTWARE + +
+3.1 - GOOGLE CLOUD +
+ +>## 3.1.1 - Google API +>>### 3.1.1.1 - Directions API +>> +>>####         Directions API + + \ No newline at end of file diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/CarriersControllers.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/CarriersControllers.java index 5a0e7ea..63fa876 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/CarriersControllers.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/CarriersControllers.java @@ -5,6 +5,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -26,4 +28,11 @@ public List listCarriers(){ } + @PostMapping() + public Carriers postCarrier(@RequestBody Carriers carrier) { + + return carriersRepository.save(carrier); + + } + } diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/ShipController.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/ShipController.java index 2608b55..a9773ef 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/ShipController.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/ShipController.java @@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.util.JSONPObject; @RestController @@ -26,28 +29,29 @@ public class ShipController { final String GOOGLE = "https://maps.googleapis.com/maps/api/directions/json?origin="; @GetMapping("/{cepOrigem}/{cepDestino}") - public JSONPObject getGoogleAPI(@PathVariable ("cepOrigem") int param1, @PathVariable ("cepDestino") int param2 ){ + public JsonNode getGoogleAPI(@PathVariable ("cepOrigem") int param1, @PathVariable ("cepDestino") int param2 ){ try { - - String APIUrl = GOOGLE+param1+"&destination="+param2+"&key=AIzaSyCKNjLUI0d01M0SfoDjIov4vZlR3DprotM"; - - URL url = new URL(APIUrl); - HttpsURLConnection get = (HttpsURLConnection) url.openConnection(); - - BufferedReader response = new BufferedReader(new InputStreamReader(get.getInputStream())); - - String jsonEmString = converteJsonEmString(response); - - JSONPObject obj = new JSONPObject(jsonEmString, null); - - return obj; - - }catch (Exception e) { - - return null; - - } + + String APIUrl = GOOGLE+param1+"&destination="+param2+"&key=AIzaSyCKNjLUI0d01M0SfoDjIov4vZlR3DprotM"; + + URL url = new URL(APIUrl); + HttpsURLConnection get = (HttpsURLConnection) url.openConnection(); + + BufferedReader response = new BufferedReader(new InputStreamReader(get.getInputStream())); + + String jsonEmString = converteJsonEmString(response); + + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = mapper.readTree(jsonEmString); + + return node; + + }catch (Exception e) { + + return null; + + } } diff --git a/frontend/main/src/app/carrier.service.spec.ts b/frontend/main/src/app/carrier.service.spec.ts new file mode 100644 index 0000000..6d132b6 --- /dev/null +++ b/frontend/main/src/app/carrier.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { CarrierService } from './carrier.service'; + +describe('CarrierService', () => { + let service: CarrierService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(CarrierService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/frontend/main/src/app/carrier.service.ts b/frontend/main/src/app/carrier.service.ts new file mode 100644 index 0000000..0bd06ed --- /dev/null +++ b/frontend/main/src/app/carrier.service.ts @@ -0,0 +1,19 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; + +@Injectable({ + providedIn: 'root' +}) +export class CarrierService { + + apiURL:string = 'http://localhost:8080/carriers' + + constructor(private router: Router, private http: HttpClient) { } + + listCarrier():any{ + + return this.http.get(this.apiURL) + + } +} diff --git a/frontend/main/src/app/loginservice.service.ts b/frontend/main/src/app/loginservice.service.ts index b4a75ed..065e399 100644 --- a/frontend/main/src/app/loginservice.service.ts +++ b/frontend/main/src/app/loginservice.service.ts @@ -16,6 +16,7 @@ export class LoginserviceService implements CanActivate { progress: boolean = false admin:boolean = false enterprise:boolean = false + pessoaID!:number constructor(private router: Router, private http: HttpClient) { } @@ -42,6 +43,7 @@ export class LoginserviceService implements CanActivate { this.user = resp.nome this.admin = resp.admin this.enterprise = resp.enterprise + this.pessoaID = response[0].pessoa_id }) return response }) diff --git a/frontend/main/src/app/quote.service.ts b/frontend/main/src/app/quote.service.ts index 12e05db..6cfa1b6 100644 --- a/frontend/main/src/app/quote.service.ts +++ b/frontend/main/src/app/quote.service.ts @@ -1,5 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; +import { type } from 'os'; import { catchError } from 'rxjs'; import { ShipQtComponent } from './ship-qt/ship-qt.component'; @@ -8,14 +10,29 @@ import { ShipQtComponent } from './ship-qt/ship-qt.component'; }) export class QuoteService { - apiURL:string = 'https://maps.googleapis.com/maps/api/directions/json?origin=' + apiURL:string = 'http://localhost:8080/ship' + apiURL2:string = 'http://localhost:8080/quote' - constructor(private http: HttpClient) { } + constructor(private router: Router, private http: HttpClient) { } quote(cepOrigem:string, cepDestino:string):any{ - return this.http.get(this.apiURL+cepOrigem+'&destination='+cepDestino+'&key=AIzaSyCKNjLUI0d01M0SfoDjIov4vZlR3DprotM') + return this.http.get(this.apiURL+'/'+cepOrigem+'/'+cepDestino) } + regRecentQuotes(object:any){ + this.http.post(this.apiURL2+'/recent',object) + .subscribe((response)=>{ + + + console.log(response); + + }) + + + } + + + } diff --git a/frontend/main/src/app/ship-qt/ship-qt.component.html b/frontend/main/src/app/ship-qt/ship-qt.component.html index 2172d2d..6ff8125 100644 --- a/frontend/main/src/app/ship-qt/ship-qt.component.html +++ b/frontend/main/src/app/ship-qt/ship-qt.component.html @@ -1,48 +1,50 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
CEP de origemCEP de destinoComprimento (cm)Largura (cm)Altura (cm)Peso (kg)
CEP de origemCEP de destinoComprimento (cm)Largura (cm)Altura (cm)Peso (kg)


- - - - - - - - + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + - - -
IDPreço do fretePrazoOrigemDestinoTransportadoraPeso cubado
SelecioneIDPreço do fretePrazoOrigemDestinoTransportadoraPeso cubado
{{i}}R${{quote.precoFrete}}{{quote.tempo}} dias úteis{{quote.start_adress}}{{quote.end_address}}{{quote.carrier}}{{quote.cubagem}} kg
{{i}}R${{quote.precoFrete}}{{quote.tempo}} dias úteis{{quote.start_adress}}{{quote.end_address}}{{quote.carrier}}{{quote.cubagem}} kg
+ + + \ No newline at end of file diff --git a/frontend/main/src/app/ship-qt/ship-qt.component.ts b/frontend/main/src/app/ship-qt/ship-qt.component.ts index ace0af0..00ee164 100644 --- a/frontend/main/src/app/ship-qt/ship-qt.component.ts +++ b/frontend/main/src/app/ship-qt/ship-qt.component.ts @@ -1,6 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; import { catchError, of } from 'rxjs'; +import { arrayBuffer, json } from 'stream/consumers'; +import { CarrierService } from '../carrier.service'; +import { LoginComponent } from '../login/login.component'; +import { LoginserviceService } from '../loginservice.service'; import { QuoteService } from '../quote.service'; @Component({ @@ -19,74 +24,102 @@ export class ShipQtComponent implements OnInit { peso!: number precoFrete!: number tempo!: number - end_address!:string - start_adress!:string - taxQuote!:number - carrier!:string - vol!:number - cubagem!:number - priceFix!:number - fatorCub!:number + end_address!: string + start_adress!: string + taxQuote!: number + carrier!: string + vol!: number + cubagem!: number + priceFix!: number + fatorCub!: number + distance!: number + carrierData = []; - constructor(public quoteService:QuoteService) {} + constructor(public loginService: LoginserviceService, public carrierService: CarrierService, public quoteService: QuoteService, private router: Router, private http: HttpClient) { } ngOnInit(): void { this.quotes = new Array() - //this.quotes.push({ precoFrete: 45.50, tempo: 3, trackid: "BR23154546TR", cepOrigem: 88058086, cepDestino: 88058086, comprimento: 50, largura: 50, altura: 50, peso: 10 }) - //this.quotes.push({ precoFrete: 94.50, tempo: 6, trackid: "BR22315445TR", cepOrigem: 46513265, cepDestino: 65898454, comprimento: 100, largura: 200, altura: 10, peso: 25 }) + //this.quotes.push({ precoFrete: 45.50, tempo: 3, trackid: "BR23154546TR", cepOrigem: 88058086, cepDestino: 88058086, comprimento: 50, largura: 50, altura: 50, peso: 10 }) + //this.quotes.push({ precoFrete: 94.50, tempo: 6, trackid: "BR22315445TR", cepOrigem: 46513265, cepDestino: 65898454, comprimento: 100, largura: 200, altura: 10, peso: 25 }) } quote() { - if(this.cepOrigem != null && this.cepDestino != null){ + if (this.cepOrigem != null && this.cepDestino != null && this.comprimento != null, this.altura != null, this.largura != null, this.peso != null) { this.quoteService.quote(this.cepOrigem, this.cepDestino) - .pipe() - .subscribe((response:any) => { - console.log(response); - console.log(response.routes[0].legs[0].distance.value); - console.log(response.routes[0].legs[0].duration.value); + .pipe() + .subscribe((response: any) => { - this.fatorCub = 300; //fator cubado - rodoviário - this.taxQuote = 0.041; - this.carrier= "Total Express"; - this.priceFix = 14.55; + console.log(response); - this.start_adress = response.routes[0].legs[0].start_address; - this.end_address = response.routes[0].legs[0].end_address; + //variaveis fixas + this.fatorCub = 300; //fator cubado - rodoviário + this.priceFix = 14.55; - this.vol = (this.comprimento*this.altura*this.largura)/1000000; + //variaveis google + this.start_adress = response.routes[0].legs[0].start_address; + this.end_address = response.routes[0].legs[0].end_address; + this.distance = (response.routes[0].legs[0].distance.value); - this.cubagem = this.vol*this.fatorCub; - console.log(this.cubagem); + //cálculos + this.vol = (this.comprimento * this.altura * this.largura) / 1000000; //conversão em m³ + this.cubagem = this.vol * this.fatorCub; + this.tempo = Math.ceil((((this.distance) / 1000) / 80) / 7); //dividido por 1000 para converter, /80 velocidade med, /7 horas diárias + //dados da transportadora + this.carrierService.listCarrier().pipe().subscribe((response: any) => { - this.tempo = Math.ceil((((response.routes[0].legs[0].distance.value)/1000)/80)/7); //dividido por 1000 para converter, /80 velocidade med, /7 horas diárias - this.precoFrete = this.priceFix + ((response.routes[0].legs[0].distance.value/10000)*this.taxQuote)*(this.cubagem); + var count = Object.keys(response).length; - console.log(this.tempo); - console.log(this.precoFrete); + for (let i = 0; i < count; i++) { + console.log(response[i].taxa); + console.log(this.priceFix + this.distance * response[i].taxa * this.cubagem); + this.precoFrete = this.priceFix + this.distance * response[i].taxa * this.cubagem; + this.quotes.push({ precoFrete: this.precoFrete, tempo: this.tempo, start_adress: this.start_adress, end_address: this.end_address, carrier: response[i].razao, vol: this.vol, cubagem: this.cubagem, carrierID: response[i].id, pessoaID: this.loginService.pessoaID }); - // this.quotes.push({precoFrete:this.precoFrete, tempo:this.tempo , start_adress:this.start_adress, end_address:this.end_address}) - this.quotes.push({precoFrete:this.precoFrete, tempo:this.tempo , start_adress:this.start_adress, end_address:this.end_address, carrier:this.carrier, vol:this.vol, cubagem:this.cubagem}); - this.cepDestino="" - this.cepOrigem="" - this.comprimento=0 - this.largura=0 - this.altura=0 - this.peso=0 - }) - }else{ + } + + }) + + this.cepDestino = "" + this.cepOrigem = "" + this.comprimento = 0 + this.largura = 0 + this.altura = 0 + this.peso = 0 + + + }) + } else { alert('DIGITE TODOS OS DADOS!') } } + regRecentQuotes(priceQuote: number, prazo: number, origem: string, destino: string, carrierID: number, cubagem: number, pessoaID:number) { + + let build ={ + "price":priceQuote, + "await":prazo, + "origin":origem, + "destiny":destino, + "carrier_id":carrierID, + "cub_height":cubagem, + "pessoa_id":pessoaID + } + + this.quoteService.regRecentQuotes(build) + + + + } + }