mirror of
https://git.hmsn.ink/kospo/svcm/api.git
synced 2026-03-20 06:13:31 +09:00
결재 로직 및 가격조사 디테일 로직 변경
This commit is contained in:
@@ -18,6 +18,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -28,6 +29,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.yaml.snakeyaml.util.UriEncoder;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.security.Principal;
|
||||
@@ -229,6 +231,39 @@ public class EstimateController {
|
||||
.body(resource);
|
||||
}
|
||||
|
||||
@Operation(summary = "견적서 ZIP 다운로드", description = "견적서(첨부파일) ZIP 다운로드")
|
||||
@ApiResponses({
|
||||
@ApiResponse(description = "Success", responseCode = "200",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(oneOf =
|
||||
{byte[].class}))),
|
||||
@ApiResponse(description = "Not found", responseCode = "404",
|
||||
content = @Content(mediaType = "text/plain", schema = @Schema(oneOf =
|
||||
{String.class}))),
|
||||
@ApiResponse(description = "Internal Error", responseCode = "500",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(oneOf =
|
||||
{CustomErrorResponse.class})))
|
||||
})
|
||||
@GetMapping("/pbAtt/{prcsNo}/{bizNo}")
|
||||
public ResponseEntity downloadZip(
|
||||
@Parameter(description = "가격조사번호") @PathVariable String prcsNo,
|
||||
@Parameter(description = "견적관리번호") @PathVariable String bizNo,
|
||||
Principal principal
|
||||
) {
|
||||
ByteArrayInputStream bais = null;
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
try {
|
||||
bais = estimateService.getPbAttCompression(prcsNo, bizNo, principal.getName());
|
||||
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + UriEncoder.encode("entry.zip"));
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
// headers.setContentLength(bais.readAllBytes().length);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ResponseEntity.ok()
|
||||
.headers(headers)
|
||||
.body(new InputStreamResource(bais));
|
||||
}
|
||||
|
||||
// @Operation(summary = "견적서 삭제", description = "견적서(첨부파일) 삭제")
|
||||
// @ApiResponses({
|
||||
// @ApiResponse(description = "Success", responseCode = "200",
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.kospo.svcm.dto.res.EstimateResponse;
|
||||
import com.kospo.svcm.model.PbAtt;
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface EstimateService {
|
||||
@@ -21,4 +23,6 @@ public interface EstimateService {
|
||||
void pbAttFileDelete(String prcsNo, String bizNo, Integer fileOrd);
|
||||
|
||||
PbAtt getPbAtt(String prcsNo, String bizNo, Integer fileOrd, String id);
|
||||
|
||||
ByteArrayInputStream getPbAttCompression(String prcsNo, String bizNo, String id) throws IOException;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@@ -29,6 +29,8 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -260,6 +262,38 @@ public class EstimateServiceImpl implements EstimateService {
|
||||
return pbAtt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteArrayInputStream getPbAttCompression(String prcsNo, String bizNo, String id) throws IOException {
|
||||
ByteArrayOutputStream baos = null;
|
||||
ZipOutputStream zos = null;
|
||||
|
||||
|
||||
baos = new ByteArrayOutputStream();
|
||||
zos = new ZipOutputStream(baos);
|
||||
List<PbAtt> pbAttList = pbAttRepository.findByIdPrcsNoAndIdBizNo(prcsNo, bizNo);
|
||||
ZipOutputStream finalZos = zos;
|
||||
pbAttList.stream().forEach(attPb -> {
|
||||
ZipEntry entry = new ZipEntry(attPb.getLogiFnm());
|
||||
try {
|
||||
finalZos.putNextEntry(entry);
|
||||
File inputFile = new File(attPb.getPath());;
|
||||
|
||||
FileInputStream fis = new FileInputStream(inputFile);
|
||||
byte[] buf = new byte[1024];
|
||||
int length;
|
||||
while((length = fis.read(buf)) > 0) {
|
||||
finalZos.write(buf, 0, length);
|
||||
}
|
||||
fis.close();
|
||||
finalZos.closeEntry();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
finalZos.close();
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void bidFileDelete(String estNo, Integer fileOrd) {
|
||||
// BidDoc bidDoc = bidDocRepository.findById(BidDocId.builder()
|
||||
|
||||
@@ -332,7 +332,7 @@ public class PrcsServiceImpl implements PrcsService {
|
||||
.apprDt("")
|
||||
.apprStatCd(apprReq.getSabun().equals(user.getSabun()) ? "0200" : apprCodeCd)
|
||||
.apprStat(apprReq.getSabun().equals(user.getSabun()) ? CommonUtils.getCodeNm(apprCodes, "0200") : CommonUtils.getCodeNm(apprCodes, apprCodeCd))
|
||||
.gubunCd(apprReq.getGubunCd())
|
||||
.gubunCd(StringUtil.isBlank(apprReq.getGubunCd()) ? "0000" : apprReq.getGubunCd())
|
||||
.gubunNm(StringUtil.isBlank(apprReq.getGubunCd()) ? "입안" : CommonUtils.getCodeNm(gubunCodes, apprReq.getGubunCd()))
|
||||
.attendCd(StringUtil.isBlank(apprReq.getAttendCd()) ? "" : apprReq.getAttendCd())
|
||||
.attendNm(StringUtil.isBlank(apprReq.getAttendCd()) ? "재중" : CommonUtils.getCodeNm(attendCodes, apprReq.getAttendCd()))
|
||||
@@ -474,12 +474,12 @@ public class PrcsServiceImpl implements PrcsService {
|
||||
.sabun(apprReqRequest.getSabun())
|
||||
.name(apprReqRequest.getName())
|
||||
.apprDt("")
|
||||
.apprStatCd(apprCodeCd)
|
||||
.apprStat(CommonUtils.getCodeNm(apprCodes, apprCodeCd))
|
||||
.gubunCd(apprReqRequest.getGubunCd())
|
||||
.gubunNm(CommonUtils.getCodeNm(gubunCodes, apprReqRequest.getGubunCd()))
|
||||
.attendCd(apprReqRequest.getAttendCd())
|
||||
.attendNm(CommonUtils.getCodeNm(attendCodes, apprReqRequest.getAttendCd()))
|
||||
.apprStatCd(apprReqRequest.getSabun().equals(apprUser.getSabun()) ? "0200" : apprCodeCd)
|
||||
.apprStat(apprReqRequest.getSabun().equals(apprUser.getSabun()) ? CommonUtils.getCodeNm(apprCodes, "0200") : CommonUtils.getCodeNm(apprCodes, apprCodeCd))
|
||||
.gubunCd(StringUtil.isBlank(apprReqRequest.getGubunCd()) ? "0000" : apprReqRequest.getGubunCd())
|
||||
.gubunNm(StringUtil.isBlank(apprReqRequest.getGubunCd()) ? "입안" : CommonUtils.getCodeNm(gubunCodes, apprReqRequest.getGubunCd()))
|
||||
.attendCd(StringUtil.isBlank(apprReqRequest.getAttendCd()) ? "" : apprReqRequest.getAttendCd())
|
||||
.attendNm(StringUtil.isBlank(apprReqRequest.getAttendCd()) ? "재중" : CommonUtils.getCodeNm(attendCodes, apprReqRequest.getAttendCd()))
|
||||
.deptCd(apprUser.getDept().getDeptCd())
|
||||
.deptNm(apprUser.getDept().getDeptNm())
|
||||
.build());
|
||||
|
||||
Reference in New Issue
Block a user