견적서 저장 에러시 오류코드 리턴 수정

This commit is contained in:
LAPTOP-L3VE7KK2\USER 2024-11-22 11:07:59 +09:00
parent b7d4729342
commit a072d87b80
2 changed files with 47 additions and 6 deletions

View File

@ -618,7 +618,7 @@ public class EstimateService {
estimateMapper.updateEstimateApi(estimateRequest);
}
} catch (Exception e) {
e.printStackTrace();
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR);
}
}
@ -1062,7 +1062,7 @@ public class EstimateService {
}
} catch (Exception e) {
e.printStackTrace();
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR);
}
}

View File

@ -23,13 +23,13 @@ import org.springframework.stereotype.Component;
public class ExcelUtil {
/**
* jxls을 이용한 엑셀다운로드
* jxls을 이용한 엑셀데이터 축출
*
* @param request HttpServletRequest
* @param response HttpServletResponse
* @param map 엑셀 출력데이터
* @param list 엑셀 출력 목록 데이터
* @param templateFileName
* @param templateFileName 템플릿 파일명
* @throws ParsePropertyException
* @throws InvalidFormatException
*/
@ -49,8 +49,6 @@ public class ExcelUtil {
InputStream templateStream =
PdfUtil.class.getClassLoader().getResourceAsStream(templateFilePath);
// InputStream is = new BufferedInputStream(templateStream);
try (InputStream is = new BufferedInputStream(templateStream)) {
Context context = new Context();
context.putVar("data", map);
@ -68,6 +66,49 @@ public class ExcelUtil {
return excelBytes;
}
/**
* jxls을 이용한 엑셀다운로드
*
* @param request HttpServletRequest
* @param response HttpServletResponse
* @param map 엑셀 출력데이터
* @param list 엑셀 출력 목록 데이터
* @param fileName 다운로드 파일명
* @param templateFileName 템플릿 파일명
* @throws ParsePropertyException
* @throws InvalidFormatException
*/
public void download(
HttpServletRequest request,
HttpServletResponse response,
Map<String, Object> map,
List<Map<String, Object>> list,
String fileName,
String templateFileName)
throws ParsePropertyException, InvalidFormatException {
try {
String templateFilePath = "template/excel/" + templateFileName;
InputStream templateStream =
PdfUtil.class.getClassLoader().getResourceAsStream(templateFilePath);
InputStream is = new BufferedInputStream(templateStream);
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + ".xlsx\"");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
try (OutputStream os = response.getOutputStream()) {
Context context = new Context();
context.putVar("data", map);
context.putVar("list", list);
JxlsHelper.getInstance().processTemplate(is, os, context);
}
} catch (Exception e) {
log.debug(e.getMessage());
}
}
/**
* Object => Map 변환 함수
*