파일업로드 API 변경
This commit is contained in:
parent
d65396b187
commit
a5c4fcb110
@ -506,6 +506,13 @@ public class EstimateService {
|
|||||||
}
|
}
|
||||||
itemRequest.setSpecialNoteCd(specialNoteCd);
|
itemRequest.setSpecialNoteCd(specialNoteCd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 첨부파일 초기화
|
||||||
|
FileRequest fileRequest = new FileRequest();
|
||||||
|
fileRequest.setObjectNo(estimateRequest.getObjectNo());
|
||||||
|
fileRequest.setPlanNo(estimateRequest.getPlanNo());
|
||||||
|
fileRequest.setUserId(estimateRequest.getUserId());
|
||||||
|
fileMapper.deleteFile(fileRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 아이템 목록 필수 값 체크
|
// 아이템 목록 필수 값 체크
|
||||||
@ -629,6 +636,21 @@ public class EstimateService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 첨부파일 처리
|
||||||
|
if (estimateRequest.getFileList() != null) {
|
||||||
|
for (FileRequest fileRequest : estimateRequest.getFileList()) {
|
||||||
|
fileRequest.setUserId(estimateRequest.getUserId());
|
||||||
|
fileMapper.insertFile(fileRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (estimateRequest.getDeleteFileList() != null) {
|
||||||
|
for (FileRequest fileRequest : estimateRequest.getDeleteFileList()) {
|
||||||
|
fileRequest.setUserId(estimateRequest.getUserId());
|
||||||
|
fileMapper.deleteFile(fileRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// QSP Q.CAST SEND API
|
// QSP Q.CAST SEND API
|
||||||
List<EstimateSendResponse> resultList = new ArrayList<EstimateSendResponse>();
|
List<EstimateSendResponse> resultList = new ArrayList<EstimateSendResponse>();
|
||||||
resultList = this.sendEstimateApi(estimateRequest);
|
resultList = this.sendEstimateApi(estimateRequest);
|
||||||
@ -676,7 +698,8 @@ public class EstimateService {
|
|||||||
objectRequest.setSaleStoreId(estimateCopyRequest.getCopySaleStoreId());
|
objectRequest.setSaleStoreId(estimateCopyRequest.getCopySaleStoreId());
|
||||||
objectRequest.setReceiveUser(
|
objectRequest.setReceiveUser(
|
||||||
StringUtils.defaultString(estimateCopyRequest.getCopyReceiveUser()));
|
StringUtils.defaultString(estimateCopyRequest.getCopyReceiveUser()));
|
||||||
objectRequest.setDelFlg("0");
|
objectRequest.setDelFlg("1");
|
||||||
|
objectRequest.setOrgDelFlg("0");
|
||||||
objectRequest.setTempFlg("0");
|
objectRequest.setTempFlg("0");
|
||||||
objectRequest.setTempDelFlg("0");
|
objectRequest.setTempDelFlg("0");
|
||||||
objectRequest.setUserId(estimateCopyRequest.getUserId());
|
objectRequest.setUserId(estimateCopyRequest.getUserId());
|
||||||
@ -1205,69 +1228,75 @@ public class EstimateService {
|
|||||||
List<EstimateSendResponse> quoteList = new ArrayList<EstimateSendResponse>();
|
List<EstimateSendResponse> quoteList = new ArrayList<EstimateSendResponse>();
|
||||||
String docNo = "";
|
String docNo = "";
|
||||||
|
|
||||||
// 견적서 상세 조회
|
try {
|
||||||
EstimateSendResponse estimateSendResponse =
|
// 견적서 상세 조회
|
||||||
estimateMapper.selectEstimateApiDetail(estimateRequest);
|
EstimateSendResponse estimateSendResponse =
|
||||||
|
estimateMapper.selectEstimateApiDetail(estimateRequest);
|
||||||
|
|
||||||
if (estimateSendResponse == null) {
|
if (estimateSendResponse == null) {
|
||||||
throw new QcastException(ErrorCode.NOT_FOUND, message.getMessage("common.message.no.data"));
|
throw new QcastException(ErrorCode.NOT_FOUND, message.getMessage("common.message.no.data"));
|
||||||
} else {
|
} else {
|
||||||
estimateSendResponse.setSaveType("3");
|
estimateSendResponse.setSaveType("3");
|
||||||
estimateSendResponse.setSyncFlg("0");
|
estimateSendResponse.setSyncFlg("0");
|
||||||
estimateSendResponse.setConstructSpecification(
|
estimateSendResponse.setConstructSpecification(
|
||||||
!StringUtils.isEmpty(estimateSendResponse.getConstructSpecification())
|
!StringUtils.isEmpty(estimateSendResponse.getConstructSpecification())
|
||||||
? estimateSendResponse.getConstructSpecification().split("、")[0]
|
? estimateSendResponse.getConstructSpecification().split("、")[0]
|
||||||
: "");
|
: "");
|
||||||
estimateSendResponse.setDelFlg("1".equals(estimateSendResponse.getDelFlg()) ? "Y" : "N");
|
estimateSendResponse.setDelFlg("1".equals(estimateSendResponse.getDelFlg()) ? "Y" : "N");
|
||||||
|
|
||||||
// 아이템 목록 조회
|
// 아이템 목록 조회
|
||||||
estimateRequest.setSchBomNotExist("1");
|
estimateRequest.setSchBomNotExist("1");
|
||||||
List<ItemResponse> estimateItemList = estimateMapper.selectEstimateItemList(estimateRequest);
|
List<ItemResponse> estimateItemList =
|
||||||
estimateSendResponse.setItemList(estimateItemList);
|
estimateMapper.selectEstimateItemList(estimateRequest);
|
||||||
|
estimateSendResponse.setItemList(estimateItemList);
|
||||||
|
|
||||||
// 첨부파일 목록 조회
|
// 첨부파일 목록 조회
|
||||||
FileRequest fileDeleteReq = new FileRequest();
|
FileRequest fileDeleteReq = new FileRequest();
|
||||||
fileDeleteReq.setObjectNo(estimateRequest.getObjectNo());
|
fileDeleteReq.setObjectNo(estimateRequest.getObjectNo());
|
||||||
fileDeleteReq.setPlanNo(estimateRequest.getPlanNo());
|
fileDeleteReq.setPlanNo(estimateRequest.getPlanNo());
|
||||||
fileDeleteReq.setCategory("10");
|
fileDeleteReq.setCategory("10");
|
||||||
|
|
||||||
List<FileResponse> fileList = fileMapper.selectFileList(fileDeleteReq);
|
List<FileResponse> fileList = fileMapper.selectFileList(fileDeleteReq);
|
||||||
estimateSendResponse.setFileList(fileList);
|
estimateSendResponse.setFileList(fileList);
|
||||||
|
|
||||||
quoteList.add(estimateSendResponse);
|
quoteList.add(estimateSendResponse);
|
||||||
estimateSendRequest.setQuoteList(quoteList);
|
estimateSendRequest.setQuoteList(quoteList);
|
||||||
}
|
}
|
||||||
|
|
||||||
EstimateApiResponse response = null;
|
EstimateApiResponse response = null;
|
||||||
/* [1]. QSP API CALL -> Response */
|
/* [1]. QSP API CALL -> Response */
|
||||||
String strResponse =
|
String strResponse =
|
||||||
interfaceQsp.callApi(
|
interfaceQsp.callApi(
|
||||||
HttpMethod.POST, QSP_API_URL + "/api/order/qcastQuotationSave", estimateSendRequest);
|
HttpMethod.POST, QSP_API_URL + "/api/order/qcastQuotationSave", estimateSendRequest);
|
||||||
|
|
||||||
if (!"".equals(strResponse)) {
|
if (!"".equals(strResponse)) {
|
||||||
com.fasterxml.jackson.databind.ObjectMapper om =
|
com.fasterxml.jackson.databind.ObjectMapper om =
|
||||||
new com.fasterxml.jackson.databind.ObjectMapper()
|
new com.fasterxml.jackson.databind.ObjectMapper()
|
||||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
response = om.readValue(strResponse, EstimateApiResponse.class);
|
response = om.readValue(strResponse, EstimateApiResponse.class);
|
||||||
|
|
||||||
Map<String, Object> result = (Map<String, Object>) response.getData();
|
Map<String, Object> result = (Map<String, Object>) response.getData();
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
List<Map<String, Object>> succList = (List<Map<String, Object>>) result.get("successList");
|
List<Map<String, Object>> succList =
|
||||||
for (Map<String, Object> succ : succList) {
|
(List<Map<String, Object>>) result.get("successList");
|
||||||
if (succ != null) {
|
for (Map<String, Object> succ : succList) {
|
||||||
for (EstimateSendResponse data : quoteList) {
|
if (succ != null) {
|
||||||
if (data.getObjectNo().equals(succ.get("objectNo"))
|
for (EstimateSendResponse data : quoteList) {
|
||||||
&& data.getPlanNo().equals(succ.get("planNo"))) {
|
if (data.getObjectNo().equals(succ.get("objectNo"))
|
||||||
data.setSyncFlg(String.valueOf(succ.get("syncFlg")));
|
&& data.getPlanNo().equals(succ.get("planNo"))) {
|
||||||
data.setDocNo(String.valueOf(succ.get("docNo")));
|
data.setSyncFlg(String.valueOf(succ.get("syncFlg")));
|
||||||
|
data.setDocNo(String.valueOf(succ.get("docNo")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.error("sendEstimateApi >>> " + message.getMessage("common.message.no.data"));
|
||||||
}
|
}
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
log.error("sendEstimateApi >>> " + message.getMessage("common.message.no.data"));
|
log.error("sendEstimateApi Error >>> " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return quoteList;
|
return quoteList;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.interplug.qcast.biz.estimate.dto;
|
package com.interplug.qcast.biz.estimate.dto;
|
||||||
|
|
||||||
|
import com.interplug.qcast.biz.file.dto.FileRequest;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -191,6 +192,12 @@ public class EstimateRequest {
|
|||||||
@Schema(description = "아이템 목록")
|
@Schema(description = "아이템 목록")
|
||||||
List<ItemRequest> itemList;
|
List<ItemRequest> itemList;
|
||||||
|
|
||||||
|
@Schema(description = "첨부파일 목록")
|
||||||
|
List<FileRequest> fileList;
|
||||||
|
|
||||||
|
@Schema(description = "삭제 첨부파일 목록")
|
||||||
|
List<FileRequest> deleteFileList;
|
||||||
|
|
||||||
@Schema(description = "다운로드 파일명")
|
@Schema(description = "다운로드 파일명")
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@ -47,7 +48,7 @@ public class FileController {
|
|||||||
@Operation(description = "파일을 업로드 한다.")
|
@Operation(description = "파일을 업로드 한다.")
|
||||||
@PostMapping("/fileUpload")
|
@PostMapping("/fileUpload")
|
||||||
@ResponseStatus(HttpStatus.OK)
|
@ResponseStatus(HttpStatus.OK)
|
||||||
public Integer fileUpload(
|
public List<FileRequest> fileUpload(
|
||||||
HttpServletRequest request, HttpServletResponse response, FileRequest fileRequest)
|
HttpServletRequest request, HttpServletResponse response, FileRequest fileRequest)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
return fileService.fileUpload(request,fileRequest);
|
return fileService.fileUpload(request,fileRequest);
|
||||||
|
|||||||
@ -102,6 +102,7 @@ public class FileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String strSrcFileNm = multipartFile.getOriginalFilename();
|
String strSrcFileNm = multipartFile.getOriginalFilename();
|
||||||
|
strSrcFileNm = this.getUniqueFileName(strFileFolderPath, strSrcFileNm);
|
||||||
File file = new File(strFileFolderPath, strSrcFileNm);
|
File file = new File(strFileFolderPath, strSrcFileNm);
|
||||||
|
|
||||||
multipartFile.transferTo(file);
|
multipartFile.transferTo(file);
|
||||||
@ -340,9 +341,39 @@ public class FileService {
|
|||||||
return iResult;
|
return iResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer fileUpload(HttpServletRequest request, FileRequest fileRequest) throws Exception {
|
public List<FileRequest> fileUpload(HttpServletRequest request, FileRequest fileRequest)
|
||||||
|
throws Exception {
|
||||||
List<FileRequest> saveFileList = this.getUploadFileList(request, fileRequest);
|
List<FileRequest> saveFileList = this.getUploadFileList(request, fileRequest);
|
||||||
Integer resultCnt = this.setFile(saveFileList, null);
|
// Integer resultCnt = this.setFile(saveFileList, null);
|
||||||
return resultCnt;
|
return saveFileList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUniqueFileName(String uploadDir, String fileName) {
|
||||||
|
File dir = new File(uploadDir);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs(); // 디렉터리가 없으면 생성
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = fileName;
|
||||||
|
String extension = "";
|
||||||
|
|
||||||
|
// 파일명과 확장자 분리
|
||||||
|
int dotIndex = fileName.lastIndexOf(".");
|
||||||
|
if (dotIndex >= 0) {
|
||||||
|
name = fileName.substring(0, dotIndex);
|
||||||
|
extension = fileName.substring(dotIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(uploadDir, fileName);
|
||||||
|
int counter = 1;
|
||||||
|
|
||||||
|
// 파일명이 중복될 경우 번호를 붙임
|
||||||
|
while (file.exists()) {
|
||||||
|
String newFileName = name + "_" + counter + extension;
|
||||||
|
file = new File(uploadDir, newFileName);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return file.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -544,6 +544,7 @@
|
|||||||
, SALT_AREA_FLG
|
, SALT_AREA_FLG
|
||||||
, TEMP_FLG
|
, TEMP_FLG
|
||||||
, TEMP_DEL_FLG
|
, TEMP_DEL_FLG
|
||||||
|
, ORG_DEL_FLG
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
#{copyObjectNo} AS OBJECT_NO
|
#{copyObjectNo} AS OBJECT_NO
|
||||||
@ -586,8 +587,9 @@
|
|||||||
, CON_TYPE
|
, CON_TYPE
|
||||||
, COLD_REGION_FLG
|
, COLD_REGION_FLG
|
||||||
, SALT_AREA_FLG
|
, SALT_AREA_FLG
|
||||||
, #{tempFlg}
|
, #{tempFlg} AS TEMP_FLG
|
||||||
, #{tempDelFlg}
|
, #{tempDelFlg} AS TEMP_DEL_FLG
|
||||||
|
, #{orgDelFlg} AS ORG_DEL_FLG
|
||||||
FROM T_OBJECT O WITH (NOLOCK)
|
FROM T_OBJECT O WITH (NOLOCK)
|
||||||
WHERE O.OBJECT_NO = #{objectNo}
|
WHERE O.OBJECT_NO = #{objectNo}
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user