Skip to content

Commit

Permalink
Merge pull request #23 from AWS-CV-Project-3355/feat/#22-diecast-graph
Browse files Browse the repository at this point in the history
[Feat] Diecast Graph
  • Loading branch information
melitina915 authored Nov 27, 2024
2 parents 94b390f + d2231e7 commit 108321c
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public DiecastResponseDTO.DiecastListDTO getDiecastList() {

}

@GetMapping(value = "/graph/okng")
@Operation(summary = "전체 양불판정 그래프 조회", description = "좌측 양불판정 통계 그래프에 NG OK 개수 보여주기")
public DiecastResponseDTO.DiecastGraphDTO getDiecastGraphOkng() {

DiecastResponseDTO.DiecastGraphDTO diecastGraphDTO = diecastQueryService.getDiecastGraphOkng();

return diecastGraphDTO;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,13 @@ public static DiecastResponseDTO.DiecastListDTO diecastListDTO(List<Diecast> die
.build();
}



public static DiecastResponseDTO.DiecastGraphDTO diecastGraphDTO(int diecastOk, int diecastNg) {
return DiecastResponseDTO.DiecastGraphDTO.builder()
.diecastOk(diecastOk)
.diecastNg(diecastNg)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,15 @@ public static class DiecastDTO {
Long diecastvideoUuid;
}



@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class DiecastGraphDTO {
int diecastOk;
int diecastNg;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import aws.teamthreefive.diecast.entity.Diecast;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DiecastRepository extends JpaRepository<Diecast, Long> {

// @Query("SELECT d.diecastOkng, COUNT(d) FROM Diecast d GROUP BY d.diecastOkng")
// List<Object[]> countByDiecastOkng();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package aws.teamthreefive.diecast.service;

import aws.teamthreefive.diecast.converter.DiecastConverter;
import aws.teamthreefive.diecast.dto.response.DiecastResponseDTO;
import aws.teamthreefive.diecast.entity.Diecast;
import aws.teamthreefive.diecast.repository.DiecastRepository;
import aws.teamthreefive.photo.entity.Photo;
Expand Down Expand Up @@ -36,4 +38,17 @@ public List<Diecast> getDiecastList() {

}

public DiecastResponseDTO.DiecastGraphDTO getDiecastGraphOkng() {

List<Diecast> diecastList = diecastRepository.findAll();

int diecastOk = (int) diecastList.stream().filter(d -> d.getDiecastOkng() == 0).count();
int diecastNg = (int) diecastList.stream().filter(d -> d.getDiecastOkng() == 1).count();

DiecastResponseDTO.DiecastGraphDTO diecastGraphDTO = DiecastConverter.diecastGraphDTO(diecastOk, diecastNg);

return diecastGraphDTO;

}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package aws.teamthreefive.photo.controller;

import aws.teamthreefive.diecast.dto.response.DiecastResponseDTO;
import aws.teamthreefive.photo.converter.PhotoConverter;
import aws.teamthreefive.photo.dto.response.PhotoResponseDTO;
import aws.teamthreefive.photo.entity.Photo;
Expand Down Expand Up @@ -40,4 +41,26 @@ public PhotoResponseDTO.PhotoListDTO getPhotoListNgCamera(

}

@GetMapping(value = "/graph/ng/type")
@Operation(summary = "전체 불량 유형 그래프 조회", description = "좌측 불량 유형 통계 그래프에 불량 유형 개수 보여주기")
public PhotoResponseDTO.PhotoGraphDTO getPhotoGraphNgType() {

PhotoResponseDTO.PhotoGraphDTO photoGraphDTO = photoQueryService.getPhotoGraphNgType();

return photoGraphDTO;

}

@GetMapping(value = "/graph/ng/type/{photoPosition}")
@Operation(summary = "카메라별 불량 유형 그래프 조회", description = "카메라별로 통계 그래프에 불량 유형 개수 보여주기")
public PhotoResponseDTO.PhotoGraphDTO getPhotoGraphNgTypePhotoPosition(
@PathVariable(name = "photoPosition") int photoPosition
) {

PhotoResponseDTO.PhotoGraphDTO photoGraphDTO = photoQueryService.getPhotoGraphNgTypePhotoPosition(photoPosition);

return photoGraphDTO;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ public static PhotoResponseDTO.PhotoListDTO photoListDTO(List<Photo> photoList)

}

public static PhotoResponseDTO.PhotoGraphDTO photoGraphDTO(int photoNgtypeOne, int photoNgtypeTwo, int photoNgtypeTree, int photoNgtypeFour) {
return PhotoResponseDTO.PhotoGraphDTO.builder()
.photoNgtypeOne(photoNgtypeOne)
.photoNgtypeTwo(photoNgtypeTwo)
.photoNgtypeThree(photoNgtypeTree)
.photoNgtypeFour(photoNgtypeFour)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,26 @@ public static class PhotoDTO {
Long diecastUuid;
}

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class PhotoGraphDTO {
int photoNgtypeOne;
int photoNgtypeTwo;
int photoNgtypeThree;
int photoNgtypeFour;
}

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class PhotoGraphPositionDTO {
int photoNgtypeOne;
int photoNgtypeTwo;
int photoNgtypeThree;
int photoNgtypeFour;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public interface PhotoRepository extends JpaRepository<Photo, Long> {

List<Photo> findAllByPhotoPositionAndPhotoNgtypeNot(int photoPosition, int photoNgtype);

List<Photo> findAllByPhotoPosition(int photoPosition);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package aws.teamthreefive.photo.service;

import aws.teamthreefive.photo.converter.PhotoConverter;
import aws.teamthreefive.photo.dto.response.PhotoResponseDTO;
import aws.teamthreefive.photo.entity.Photo;
import aws.teamthreefive.photo.repository.PhotoRepository;
import jakarta.transaction.Transactional;
Expand Down Expand Up @@ -31,4 +33,34 @@ public List<Photo> getPhotoListNgCamera(int photoPosition) {

}

public PhotoResponseDTO.PhotoGraphDTO getPhotoGraphNgType() {

List<Photo> photoList = photoRepository.findAll();

int photoNgtypeOne = (int) photoList.stream().filter(p -> p.getPhotoNgtype() == 1).count();
int photoNgtypeTwo = (int) photoList.stream().filter(p -> p.getPhotoNgtype() == 2).count();
int photoNgtypeThree = (int) photoList.stream().filter(p -> p.getPhotoNgtype() == 3).count();
int photoNgtypeFour = (int) photoList.stream().filter(p -> p.getPhotoNgtype() == 4).count();

PhotoResponseDTO.PhotoGraphDTO photoGraphDTO = PhotoConverter.photoGraphDTO(photoNgtypeOne, photoNgtypeTwo, photoNgtypeThree, photoNgtypeFour);

return photoGraphDTO;

}

public PhotoResponseDTO.PhotoGraphDTO getPhotoGraphNgTypePhotoPosition(int photoPosition) {

List<Photo> photoList = photoRepository.findAllByPhotoPosition(photoPosition);

int photoNgtypeOne = (int) photoList.stream().filter(p -> p.getPhotoNgtype() == 1).count();
int photoNgtypeTwo = (int) photoList.stream().filter(p -> p.getPhotoNgtype() == 2).count();
int photoNgtypeThree = (int) photoList.stream().filter(p -> p.getPhotoNgtype() == 3).count();
int photoNgtypeFour = (int) photoList.stream().filter(p -> p.getPhotoNgtype() == 4).count();

PhotoResponseDTO.PhotoGraphDTO photoGraphDTO = PhotoConverter.photoGraphDTO(photoNgtypeOne, photoNgtypeTwo, photoNgtypeThree, photoNgtypeFour);

return photoGraphDTO;

}

}

0 comments on commit 108321c

Please sign in to comment.