diff --git a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java index bdaa0115..573acfc8 100644 --- a/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java +++ b/src/main/java/com/interplug/qcast/biz/estimate/EstimateService.java @@ -34,18 +34,11 @@ import com.interplug.qcast.util.InterfaceQsp; import com.interplug.qcast.util.PdfUtil; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; @@ -1019,8 +1012,8 @@ public class EstimateService { excelUtil.download( request, response, - this.convertVoToMap(estimateResponse), - this.convertListToMap(estimateItemList), + excelUtil.convertVoToMap(estimateResponse), + excelUtil.convertListToMap(estimateItemList), estimateRequest.getFileName(), excelTemplateNam); } @@ -1557,60 +1550,6 @@ public class EstimateService { return doc; } - /** - * Object => Map 변환 함수 - * - * @param vo Object - * @return Map Map 변환 정보 - */ - public Map convertVoToMap(Object vo) { - Map result = new HashMap(); - - try { - BeanInfo info = Introspector.getBeanInfo(vo.getClass()); - for (PropertyDescriptor pd : info.getPropertyDescriptors()) { - Method reader = pd.getReadMethod(); - if (reader != null) { - result.put(pd.getName(), reader.invoke(vo)); - } - } - } catch (Exception e) { - log.error("convertVoToMap >>> " + e.getMessage()); - } - return result; - } - - /** - * List => List 변환 함수 - * - * @param target List - * @return List> List 변환 정보 - */ - public static List> convertListToMap(Collection target) { - List> resultList = new ArrayList>(); - - for (T element : target) { - Map resultMap = new HashMap(); - Field[] fieldList = element.getClass().getDeclaredFields(); - if (fieldList != null && fieldList.length > 0) { - try { - for (int i = 0; i < fieldList.length; i++) { - String curInsName = fieldList[i].getName(); - Field field = element.getClass().getDeclaredField(curInsName); - field.setAccessible(true); - Object targetValue = field.get(element); - - resultMap.put(curInsName, targetValue); - } - resultList.add(resultMap); - } catch (Exception e) { - log.error("convertListToMap >>> " + e.getMessage()); - } - } - } - return resultList; - } - /** * Plan 확정 정보 동기화 * diff --git a/src/main/java/com/interplug/qcast/util/ExcelUtil.java b/src/main/java/com/interplug/qcast/util/ExcelUtil.java index 37ed9e7b..9d1a543b 100644 --- a/src/main/java/com/interplug/qcast/util/ExcelUtil.java +++ b/src/main/java/com/interplug/qcast/util/ExcelUtil.java @@ -3,9 +3,13 @@ package com.interplug.qcast.util; import com.fasterxml.jackson.databind.exc.InvalidFormatException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; import java.io.*; -import java.util.List; -import java.util.Map; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.sf.jxls.exception.ParsePropertyException; @@ -60,4 +64,58 @@ public class ExcelUtil { log.debug(e.getMessage()); } } + + /** + * Object => Map 변환 함수 + * + * @param vo Object + * @return Map Map 변환 정보 + */ + public Map convertVoToMap(Object vo) { + Map result = new HashMap(); + + try { + BeanInfo info = Introspector.getBeanInfo(vo.getClass()); + for (PropertyDescriptor pd : info.getPropertyDescriptors()) { + Method reader = pd.getReadMethod(); + if (reader != null) { + result.put(pd.getName(), reader.invoke(vo)); + } + } + } catch (Exception e) { + log.error("convertVoToMap >>> " + e.getMessage()); + } + return result; + } + + /** + * List => List 변환 함수 + * + * @param target List + * @return List> List 변환 정보 + */ + public static List> convertListToMap(Collection target) { + List> resultList = new ArrayList>(); + + for (T element : target) { + Map resultMap = new HashMap(); + Field[] fieldList = element.getClass().getDeclaredFields(); + if (fieldList != null && fieldList.length > 0) { + try { + for (int i = 0; i < fieldList.length; i++) { + String curInsName = fieldList[i].getName(); + Field field = element.getClass().getDeclaredField(curInsName); + field.setAccessible(true); + Object targetValue = field.get(element); + + resultMap.put(curInsName, targetValue); + } + resultList.add(resultMap); + } catch (Exception e) { + log.error("convertListToMap >>> " + e.getMessage()); + } + } + } + return resultList; + } }