This commit is contained in:
dirgantarasiahaan
2023-06-04 00:06:01 +07:00
parent dbbde49f59
commit abc89d32d0
10 changed files with 125 additions and 26 deletions

View File

@@ -0,0 +1,44 @@
package com.iconplus.smartproc.service.print;
import com.iconplus.smartproc.helper.model.EmptyResponse;
import com.iconplus.smartproc.helper.service.BaseService;
import com.iconplus.smartproc.model.projection.DrpApprovalView;
import com.iconplus.smartproc.model.request.PrintDrpRequest;
import com.iconplus.smartproc.repository.DrpApprovalRepository;
import com.iconplus.smartproc.service.CommonService;
import org.springframework.stereotype.Service;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
@Service
public class DrpPrintExecutionService implements BaseService<PrintDrpRequest, EmptyResponse> {
private final CommonService commonService;
private final DrpApprovalRepository drpApprovalRepository;
public DrpPrintExecutionService(CommonService commonService,
DrpApprovalRepository drpApprovalRepository) {
this.commonService = commonService;
this.drpApprovalRepository = drpApprovalRepository;
}
@Override
public EmptyResponse execute(PrintDrpRequest input) throws Exception {
var drpApprovalViews = drpApprovalRepository.getDrpApproval(input.getDrpId());
int size = drpApprovalViews.size();
List<BufferedImage> bufferedImageList = new ArrayList<>();
for (DrpApprovalView drpApprovalView : drpApprovalViews) {
String barcodeText = drpApprovalView.getApproverUserId().toString() + " - " + drpApprovalView.getNama() + " - " + drpApprovalView.getJabatan();
var bufferedImage = commonService.generateQRCodeImage(barcodeText);
bufferedImageList.add(bufferedImage);
}
return new EmptyResponse();
}
}