From f1f071b512b06cbd6b911a34be91f01c4bb5dbd3 Mon Sep 17 00:00:00 2001 From: dirgantarasiahaan Date: Fri, 2 Jun 2023 18:21:29 +0700 Subject: [PATCH] add api drp list rekomendasi --- .../controller/ApprovalDrpController.java | 24 ++++-- .../smartproc/controller/DrpController.java | 19 ++++- .../smartproc/controller/PrintController.java | 37 +++++++++ .../model/projection/DrpApprovalView.java | 6 ++ .../model/projection/DrpRekomendasiView.java | 9 +++ .../smartproc/model/projection/DrpView.java | 7 ++ .../model/request/DrpRekomendasiRequest.java | 2 + .../model/request/PrintDrpRequest.java | 17 +++++ .../response/DrpRekomendasiResponse.java | 2 +- .../response/GetListPrintDrpResponse.java | 20 +++++ .../model/response/PrintDrpResponse.java | 21 ++++++ .../repository/DrpRekomendasiRepository.java | 32 ++++++++ .../smartproc/repository/DrpRepository.java | 11 +++ .../service/approval/GetApprovalService.java | 10 ++- .../approval/GetListRekomendasiService.java | 39 +++++++++- .../drp/GetListDrpRekomendasiService.java | 75 +++++++++++++++++++ .../service/print/GetListPrintDrpService.java | 57 ++++++++++++++ 17 files changed, 376 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/iconplus/smartproc/controller/PrintController.java create mode 100644 src/main/java/com/iconplus/smartproc/model/request/PrintDrpRequest.java create mode 100644 src/main/java/com/iconplus/smartproc/model/response/GetListPrintDrpResponse.java create mode 100644 src/main/java/com/iconplus/smartproc/model/response/PrintDrpResponse.java create mode 100644 src/main/java/com/iconplus/smartproc/service/drp/GetListDrpRekomendasiService.java create mode 100644 src/main/java/com/iconplus/smartproc/service/print/GetListPrintDrpService.java diff --git a/src/main/java/com/iconplus/smartproc/controller/ApprovalDrpController.java b/src/main/java/com/iconplus/smartproc/controller/ApprovalDrpController.java index fe98928..dfb7e3c 100644 --- a/src/main/java/com/iconplus/smartproc/controller/ApprovalDrpController.java +++ b/src/main/java/com/iconplus/smartproc/controller/ApprovalDrpController.java @@ -5,10 +5,7 @@ import com.iconplus.smartproc.helper.model.EmptyResponse; import com.iconplus.smartproc.model.request.DrpApprovalRequest; import com.iconplus.smartproc.model.request.DrpRekomendasiRequest; import com.iconplus.smartproc.model.request.ListDrpApprovalRequest; -import com.iconplus.smartproc.model.response.DrpApprovalResponse; -import com.iconplus.smartproc.model.response.DrpRekomendasiResponse; -import com.iconplus.smartproc.model.response.GetListDrpApprovalResponse; -import com.iconplus.smartproc.model.response.GetListUserApprovalResponse; +import com.iconplus.smartproc.model.response.*; import com.iconplus.smartproc.service.approval.*; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -26,13 +23,15 @@ public class ApprovalDrpController { private PostDrpRekomendasiService postDrpRekomendasiService; private PostDrpApprovalExecutionService postDrpApprovalExecutionService; private GetApprovalService getApprovalService; + private GetListRekomendasiService getListRekomendasiService; public ApprovalDrpController(GetListUserVpService getListUserVpService, GetListUserDirekturKomiteService getListUserDirekturKomiteService, PostCreateDrpApprovalService postCreateDrpApprovalService, GetListApprovalDrpServie getListApprovalDrpServie, PostDrpRekomendasiService postDrpRekomendasiService, PostDrpApprovalExecutionService postDrpApprovalExecutionService, - GetApprovalService getApprovalService) { + GetApprovalService getApprovalService, + GetListRekomendasiService getListRekomendasiService) { this.getListUserVpService = getListUserVpService; this.getListUserDirekturKomiteService = getListUserDirekturKomiteService; this.postCreateDrpApprovalService = postCreateDrpApprovalService; @@ -40,6 +39,7 @@ public class ApprovalDrpController { this.postDrpRekomendasiService = postDrpRekomendasiService; this.postDrpApprovalExecutionService = postDrpApprovalExecutionService; this.getApprovalService = getApprovalService; + this.getListRekomendasiService = getListRekomendasiService; } @GetMapping("/vp") @@ -87,4 +87,18 @@ public class ApprovalDrpController { .jenisPengadaanId(id) .build()); } + + @GetMapping("/rekomendasi/jenis-pengadaan/{id}") + public GetListDrpRekomendasiResponse getListRekomendasi(@PathVariable(name = "id") Long id, + @RequestParam(name = "page", defaultValue = "1") Integer page, + @RequestParam(name = "size", defaultValue = "5") Integer size) { + + Pageable pageable = PageRequest.of((page - 1), size); + DrpRekomendasiRequest drpRekomendasiRequest = DrpRekomendasiRequest.builder() + .jenisPengadaanId(id) + .pageable(pageable) + .build(); + + return getListRekomendasiService.execute(drpRekomendasiRequest); + } } diff --git a/src/main/java/com/iconplus/smartproc/controller/DrpController.java b/src/main/java/com/iconplus/smartproc/controller/DrpController.java index d92ab8b..58eaee7 100644 --- a/src/main/java/com/iconplus/smartproc/controller/DrpController.java +++ b/src/main/java/com/iconplus/smartproc/controller/DrpController.java @@ -2,6 +2,7 @@ package com.iconplus.smartproc.controller; import com.iconplus.smartproc.helper.model.EmptyResponse; import com.iconplus.smartproc.model.request.DrpDokumenRequest; +import com.iconplus.smartproc.model.request.DrpRekomendasiRequest; import com.iconplus.smartproc.model.request.DrpRequest; import com.iconplus.smartproc.model.response.*; import com.iconplus.smartproc.service.drp.*; @@ -24,6 +25,7 @@ public class DrpController { private final DeleteDokumenUploadService deleteDokumenUploadService; private final PostCreateDrpService postCreateDrpService; private final EditUploadDokumenDrpService editUploadDokumenDrpService; + private final GetListDrpRekomendasiService getListDrpRekomendasiService; public DrpController(GetDrpService getDrpService, GetListDrpService getListDrpService, @@ -31,7 +33,8 @@ public class DrpController { PostCreateTahunDrpService postCreateTahunDrpService, DeleteDokumenUploadService deleteDokumenUploadService, PostCreateDrpService postCreateDrpService, - EditUploadDokumenDrpService editUploadDokumenDrpService) { + EditUploadDokumenDrpService editUploadDokumenDrpService, + GetListDrpRekomendasiService getListDrpRekomendasiService) { this.getDrpService = getDrpService; this.getListDrpService = getListDrpService; this.postDrpUploadDokumenRKAPService = postDrpUploadDokumenRKAPService; @@ -39,6 +42,7 @@ public class DrpController { this.deleteDokumenUploadService = deleteDokumenUploadService; this.postCreateDrpService = postCreateDrpService; this.editUploadDokumenDrpService = editUploadDokumenDrpService; + this.getListDrpRekomendasiService = getListDrpRekomendasiService; } @GetMapping @@ -102,4 +106,17 @@ public class DrpController { .build()); } + @GetMapping("/{id}/rekomendasi") + public GetListDrpRekomendasiResponse getListDrpRekomendasiResponse(@PathVariable(name = "id") Long id, + @RequestParam(name = "page", defaultValue = "1") Integer page, + @RequestParam(name = "size", defaultValue = "5") Integer size) { + Pageable pageable = PageRequest.of((page - 1), size); + DrpRekomendasiRequest drpRekomendasiRequest = DrpRekomendasiRequest.builder() + .drpId(id) + .pageable(pageable) + .build(); + + return getListDrpRekomendasiService.execute(drpRekomendasiRequest); + } + } diff --git a/src/main/java/com/iconplus/smartproc/controller/PrintController.java b/src/main/java/com/iconplus/smartproc/controller/PrintController.java new file mode 100644 index 0000000..a02741a --- /dev/null +++ b/src/main/java/com/iconplus/smartproc/controller/PrintController.java @@ -0,0 +1,37 @@ +package com.iconplus.smartproc.controller; + +import com.iconplus.smartproc.model.request.PrintDrpRequest; +import com.iconplus.smartproc.model.request.RolesRequest; +import com.iconplus.smartproc.model.response.GetListPrintDrpResponse; +import com.iconplus.smartproc.service.print.GetListPrintDrpService; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.*; + +@CrossOrigin(origins = "${fe.server}", allowCredentials = "true") +@RestController +@RequestMapping("/api/drp/cetak") +public class PrintController { + + private final GetListPrintDrpService getListPrintDrpService; + + public PrintController(GetListPrintDrpService getListPrintDrpService) { + this.getListPrintDrpService = getListPrintDrpService; + + } + + @GetMapping + public GetListPrintDrpResponse getListPrintDrpResponse(@RequestParam(name = "page", defaultValue = "1") Integer page, + @RequestParam(name = "size", defaultValue = "5") Integer size) { + + Pageable pageable = PageRequest.of((page - 1), size); + PrintDrpRequest printDrpRequest = PrintDrpRequest.builder() + .pageable(pageable) + .build(); + + return getListPrintDrpService.execute(printDrpRequest); + + } + + +} diff --git a/src/main/java/com/iconplus/smartproc/model/projection/DrpApprovalView.java b/src/main/java/com/iconplus/smartproc/model/projection/DrpApprovalView.java index 0da75aa..8ba5585 100644 --- a/src/main/java/com/iconplus/smartproc/model/projection/DrpApprovalView.java +++ b/src/main/java/com/iconplus/smartproc/model/projection/DrpApprovalView.java @@ -26,6 +26,12 @@ public interface DrpApprovalView { Date getDirekturApproveDate(); void setDirekturApproveDate(Date direkturApproveDate); + Boolean getIsPrint(); + void setIsPrint(Boolean isPrint); + + Date getPrintDate(); + void setPrintDate(Date printDate); + } diff --git a/src/main/java/com/iconplus/smartproc/model/projection/DrpRekomendasiView.java b/src/main/java/com/iconplus/smartproc/model/projection/DrpRekomendasiView.java index 0c2ab08..9d5738f 100644 --- a/src/main/java/com/iconplus/smartproc/model/projection/DrpRekomendasiView.java +++ b/src/main/java/com/iconplus/smartproc/model/projection/DrpRekomendasiView.java @@ -20,4 +20,13 @@ public interface DrpRekomendasiView { String getRekomendasi(); void setRekomendasiDate(String rekomendasi); + String getNomor(); + void setNomor(String nomor); + + String getNamaPengadaan(); + void setNamaPengadaan(String namaPengadaan); + + String getLevel(); + void setLevel(String level); + } diff --git a/src/main/java/com/iconplus/smartproc/model/projection/DrpView.java b/src/main/java/com/iconplus/smartproc/model/projection/DrpView.java index fe0c8af..81bfadb 100644 --- a/src/main/java/com/iconplus/smartproc/model/projection/DrpView.java +++ b/src/main/java/com/iconplus/smartproc/model/projection/DrpView.java @@ -1,5 +1,6 @@ package com.iconplus.smartproc.model.projection; +import java.sql.Date; import java.sql.Timestamp; public interface DrpView { @@ -16,6 +17,12 @@ public interface DrpView { Timestamp getApproveDate(); void setApproveDate(Timestamp approveDate); + Boolean getIsPrint(); + void setIsPrint(Boolean isPrint); + + Date getPrintDate(); + void setPrintDate(Date printDate); + Boolean getIsActive(); void setIsActive(Boolean isActive); diff --git a/src/main/java/com/iconplus/smartproc/model/request/DrpRekomendasiRequest.java b/src/main/java/com/iconplus/smartproc/model/request/DrpRekomendasiRequest.java index c54f5cc..015e9c5 100644 --- a/src/main/java/com/iconplus/smartproc/model/request/DrpRekomendasiRequest.java +++ b/src/main/java/com/iconplus/smartproc/model/request/DrpRekomendasiRequest.java @@ -5,6 +5,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.springframework.data.domain.Pageable; import java.sql.Date; @@ -21,6 +22,7 @@ public class DrpRekomendasiRequest extends BaseRequest { private Long jenisPengadaanId; private String rekomendasi; private Date rekomendasiDate; + private transient Pageable pageable; diff --git a/src/main/java/com/iconplus/smartproc/model/request/PrintDrpRequest.java b/src/main/java/com/iconplus/smartproc/model/request/PrintDrpRequest.java new file mode 100644 index 0000000..ff07db5 --- /dev/null +++ b/src/main/java/com/iconplus/smartproc/model/request/PrintDrpRequest.java @@ -0,0 +1,17 @@ +package com.iconplus.smartproc.model.request; + +import com.iconplus.smartproc.helper.base.BaseRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.data.domain.Pageable; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PrintDrpRequest extends BaseRequest { + + private transient Pageable pageable; +} diff --git a/src/main/java/com/iconplus/smartproc/model/response/DrpRekomendasiResponse.java b/src/main/java/com/iconplus/smartproc/model/response/DrpRekomendasiResponse.java index 9dc9cb2..1fc1eec 100644 --- a/src/main/java/com/iconplus/smartproc/model/response/DrpRekomendasiResponse.java +++ b/src/main/java/com/iconplus/smartproc/model/response/DrpRekomendasiResponse.java @@ -23,5 +23,5 @@ public class DrpRekomendasiResponse extends BaseResponse { private Date approveDate; private Date rekomendasiDate; private String rekomendasi; - private String jabatan; + private String jabatan;; } diff --git a/src/main/java/com/iconplus/smartproc/model/response/GetListPrintDrpResponse.java b/src/main/java/com/iconplus/smartproc/model/response/GetListPrintDrpResponse.java new file mode 100644 index 0000000..8465992 --- /dev/null +++ b/src/main/java/com/iconplus/smartproc/model/response/GetListPrintDrpResponse.java @@ -0,0 +1,20 @@ +package com.iconplus.smartproc.model.response; + +import com.iconplus.smartproc.helper.base.BaseResponse; +import com.iconplus.smartproc.helper.model.Pagination; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class GetListPrintDrpResponse extends BaseResponse { + + private List data; + private Pagination pagination; +} diff --git a/src/main/java/com/iconplus/smartproc/model/response/PrintDrpResponse.java b/src/main/java/com/iconplus/smartproc/model/response/PrintDrpResponse.java new file mode 100644 index 0000000..2d3b4ee --- /dev/null +++ b/src/main/java/com/iconplus/smartproc/model/response/PrintDrpResponse.java @@ -0,0 +1,21 @@ +package com.iconplus.smartproc.model.response; + +import com.iconplus.smartproc.helper.base.BaseResponse; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.sql.Date; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PrintDrpResponse extends BaseResponse { + + private Long id; + private Integer tahun; + private String status; + private Date printDate; +} diff --git a/src/main/java/com/iconplus/smartproc/repository/DrpRekomendasiRepository.java b/src/main/java/com/iconplus/smartproc/repository/DrpRekomendasiRepository.java index 896d523..49ed28d 100644 --- a/src/main/java/com/iconplus/smartproc/repository/DrpRekomendasiRepository.java +++ b/src/main/java/com/iconplus/smartproc/repository/DrpRekomendasiRepository.java @@ -2,6 +2,8 @@ package com.iconplus.smartproc.repository; import com.iconplus.smartproc.model.entity.DrpRekomendasi; import com.iconplus.smartproc.model.projection.DrpRekomendasiView; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @@ -23,4 +25,34 @@ public interface DrpRekomendasiRepository extends JpaRepository getListDrpRekomendasi(Long jenisPengadaanId); + + @Query(value = "SELECT dr.id as id, " + + "da.isApprove as isApprove, " + + "j.jabatan as jabatan, " + + "dr.rekomendasi as rekomendasi, " + + "dr.rekomendasiDate as rekomendasiDate " + + "FROM DrpRekomendasi dr " + + "JOIN DrpApproval da ON da.id = dr.drpApprovalId " + + "JOIN Users u ON u.id = dr.userId " + + "JOIN Jabatan j ON j.id = u.jabatanId " + + "WHERE dr.isDelete = false " + + "AND dr.jenisPengadaanId = :jenisPengadaanId") + Page getListDrpRekomendasi(Long jenisPengadaanId, Pageable pageable); + + @Query(value = "SELECT dr.id as id, " + + "dp.nomor as nomor, " + + "dp.namaPengadaan as namaPengadaan, " + + "da.isApprove as isApprove, " + + "da.level as level, " + + "j.jabatan as jabatan, " + + "dr.rekomendasi as rekomendasi, " + + "dr.rekomendasiDate as rekomendasiDate " + + "FROM DrpRekomendasi dr " + + "JOIN DrpApproval da ON da.id = dr.drpApprovalId " + + "JOIN Users u ON u.id = dr.userId " + + "JOIN Jabatan j ON j.id = u.jabatanId " + + "JOIN DrpPengadaan dp ON dp.id = dr.jenisPengadaanId " + + "WHERE dr.isDelete = false " + + "AND dr.drpId = :drpId") + Page getListDrpRekomendasiByDrpId(Long drpId, Pageable pageable); } diff --git a/src/main/java/com/iconplus/smartproc/repository/DrpRepository.java b/src/main/java/com/iconplus/smartproc/repository/DrpRepository.java index a4d4acc..62397a5 100644 --- a/src/main/java/com/iconplus/smartproc/repository/DrpRepository.java +++ b/src/main/java/com/iconplus/smartproc/repository/DrpRepository.java @@ -44,4 +44,15 @@ public interface DrpRepository extends JpaRepository { "FROM Drp d " + "WHERE d.isDelete = false") Page getListApprovalDrp(Pageable pageable); + + + + @Query(value = "SELECT d.id as id, " + + "d.tahun as tahun, " + + "d.isPrint as isPrint, " + + "d.printDate as printDate " + + "FROM Drp d " + + "WHERE d.isDelete = false") + Page getListPrintDrp(Pageable pageable); + } diff --git a/src/main/java/com/iconplus/smartproc/service/approval/GetApprovalService.java b/src/main/java/com/iconplus/smartproc/service/approval/GetApprovalService.java index 2414737..c8e70be 100644 --- a/src/main/java/com/iconplus/smartproc/service/approval/GetApprovalService.java +++ b/src/main/java/com/iconplus/smartproc/service/approval/GetApprovalService.java @@ -94,10 +94,12 @@ public class GetApprovalService implements BaseService { @@ -19,6 +25,37 @@ public class GetListRekomendasiService implements BaseService drpRekomendasiResponseList = new ArrayList<>(); + var listDrpRekomendasi = drpRekomendasiRepository.getListDrpRekomendasi(input.getJenisPengadaanId(), input.getPageable()); + for (DrpRekomendasiView drpRekomendasiView : listDrpRekomendasi) { + DrpRekomendasiResponse drpRekomendasiResponse = DrpRekomendasiResponse.builder() + .id(drpRekomendasiView.getId()) + .jabatan(drpRekomendasiView.getJabatan()) + .rekomendasi(drpRekomendasiView.getRekomendasi()) + .rekomendasiDate(drpRekomendasiView.getRekomendasiDate()) + .build(); + if (drpRekomendasiView.getIsApprove() != null) { + if (BooleanUtils.isTrue(drpRekomendasiView.getIsApprove())) { + drpRekomendasiResponse.setStatus("Setuju"); + } else { + drpRekomendasiResponse.setStatus("Tolak"); + } + } + + drpRekomendasiResponseList.add(drpRekomendasiResponse); + } + + return GetListDrpRekomendasiResponse.builder() + .data(drpRekomendasiResponseList) + .pagination(Pagination.builder() + .pageSize(input.getPageable().getPageSize()) + .currentPage(input.getPageable().getPageNumber()) + .totalPages(listDrpRekomendasi.getTotalPages()) + .totalRecords(listDrpRekomendasi.getTotalElements()) + .isFirstPage(listDrpRekomendasi.isFirst()) + .isLastPage(listDrpRekomendasi.isLast()) + .build()) + .build(); } } diff --git a/src/main/java/com/iconplus/smartproc/service/drp/GetListDrpRekomendasiService.java b/src/main/java/com/iconplus/smartproc/service/drp/GetListDrpRekomendasiService.java new file mode 100644 index 0000000..b539ab0 --- /dev/null +++ b/src/main/java/com/iconplus/smartproc/service/drp/GetListDrpRekomendasiService.java @@ -0,0 +1,75 @@ +package com.iconplus.smartproc.service.drp; + +import com.iconplus.smartproc.helper.model.Pagination; +import com.iconplus.smartproc.helper.service.BaseService; +import com.iconplus.smartproc.model.projection.DrpRekomendasiView; +import com.iconplus.smartproc.model.request.DrpRekomendasiRequest; +import com.iconplus.smartproc.model.response.DrpRekomendasiResponse; +import com.iconplus.smartproc.model.response.GetListDrpRekomendasiResponse; +import com.iconplus.smartproc.repository.DrpRekomendasiRepository; +import com.iconplus.smartproc.util.Constants; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class GetListDrpRekomendasiService implements BaseService { + + private final DrpRekomendasiRepository drpRekomendasiRepository; + + public GetListDrpRekomendasiService(DrpRekomendasiRepository drpRekomendasiRepository) { + this.drpRekomendasiRepository = drpRekomendasiRepository; + } + + + @Override + public GetListDrpRekomendasiResponse execute(DrpRekomendasiRequest input) { + + List drpRekomendasiResponseList = new ArrayList<>(); + var listDrpRekomendasi = drpRekomendasiRepository.getListDrpRekomendasiByDrpId(input.getDrpId(), input.getPageable()); + for (DrpRekomendasiView drpRekomendasiView : listDrpRekomendasi) { + DrpRekomendasiResponse drpRekomendasiResponse = DrpRekomendasiResponse.builder() + .id(drpRekomendasiView.getId()) + .nomorRkp(drpRekomendasiView.getNomor()) + .namaPengadaan(drpRekomendasiView.getNamaPengadaan()) + .jabatan(drpRekomendasiView.getJabatan()) + .rekomendasi(drpRekomendasiView.getRekomendasi()) + .rekomendasiDate(drpRekomendasiView.getRekomendasiDate()) + .build(); + + if (drpRekomendasiView.getIsApprove() != null) { + if (BooleanUtils.isTrue(drpRekomendasiView.getIsApprove())) { + drpRekomendasiResponse.setStatus("Setuju"); + } else { + drpRekomendasiResponse.setStatus("Tolak"); + } + + if (StringUtils.equalsIgnoreCase("VP", drpRekomendasiView.getLevel())) { + drpRekomendasiResponse.setApproval(Constants.STATUS_APPROVAL_VP); + } else if (StringUtils.equalsIgnoreCase("KOMITE", drpRekomendasiView.getLevel())) { + drpRekomendasiResponse.setApproval(Constants.STATUS_REKOMENDASI_KOMITE); + } else { + drpRekomendasiResponse.setApproval(Constants.STATUS_APPROVAL_DIRUT); + } + } + + drpRekomendasiResponseList.add(drpRekomendasiResponse); + } + + return GetListDrpRekomendasiResponse.builder() + .data(drpRekomendasiResponseList) + .pagination(Pagination.builder() + .pageSize(input.getPageable().getPageSize()) + .currentPage(input.getPageable().getPageNumber()) + .totalPages(listDrpRekomendasi.getTotalPages()) + .totalRecords(listDrpRekomendasi.getTotalElements()) + .isFirstPage(listDrpRekomendasi.isFirst()) + .isLastPage(listDrpRekomendasi.isLast()) + .build()) + .build(); + } + +} diff --git a/src/main/java/com/iconplus/smartproc/service/print/GetListPrintDrpService.java b/src/main/java/com/iconplus/smartproc/service/print/GetListPrintDrpService.java new file mode 100644 index 0000000..d8e84d5 --- /dev/null +++ b/src/main/java/com/iconplus/smartproc/service/print/GetListPrintDrpService.java @@ -0,0 +1,57 @@ +package com.iconplus.smartproc.service.print; + +import com.iconplus.smartproc.helper.model.Pagination; +import com.iconplus.smartproc.helper.service.BaseService; +import com.iconplus.smartproc.model.projection.DrpView; +import com.iconplus.smartproc.model.request.PrintDrpRequest; +import com.iconplus.smartproc.model.response.GetListPrintDrpResponse; +import com.iconplus.smartproc.model.response.PrintDrpResponse; +import com.iconplus.smartproc.repository.DrpRepository; +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class GetListPrintDrpService implements BaseService { + + private DrpRepository drpRepository; + + public GetListPrintDrpService(DrpRepository drpRepository) { + this.drpRepository = drpRepository; + } + + + @Override + public GetListPrintDrpResponse execute(PrintDrpRequest input) { + + List printDrpResponseList = new ArrayList<>(); + + var drpViews = drpRepository.getListPrintDrp(input.getPageable()); + for (DrpView drpView : drpViews) { + PrintDrpResponse printDrpResponse = PrintDrpResponse.builder() + .id(drpView.getId()) + .printDate(drpView.getPrintDate()) + .build(); + if (BooleanUtils.isTrue(drpView.getIsPrint())) { + printDrpResponse.setStatus("Tercetak"); + } else { + printDrpResponse.setStatus("Belum Bisa Dicetak"); + } + printDrpResponseList.add(printDrpResponse); + } + + return GetListPrintDrpResponse.builder() + .data(printDrpResponseList) + .pagination(Pagination.builder() + .pageSize(input.getPageable().getPageSize()) + .currentPage(input.getPageable().getPageNumber()) + .totalPages(drpViews.getTotalPages()) + .totalRecords(drpViews.getTotalElements()) + .isFirstPage(drpViews.isFirst()) + .isLastPage(drpViews.isLast()) + .build()) + .build(); + } +}