단속관리 엑셀저장 수정

main
이범준 11 months ago
parent 99c88c662d
commit 82f4f58b6d

@ -9,6 +9,9 @@ public class CmmnQuery extends QueryRequest {
private String mainOption;
private String subOption;
private String[] excelTitle;
private int[] excelTitleWidth;
private String thisDay;
private String sggCd; // 시군구 코드
@ -46,6 +49,24 @@ public class CmmnQuery extends QueryRequest {
return self();
}
public String[] getExcelTitle() {
return ifEmpty(excelTitle, () -> null);
}
public <T extends CmmnQuery> T setExcelTitle(String[] excelTitle) {
this.excelTitle = excelTitle;
return self();
}
public int[] getExcelTitleWidth() {
return ifEmpty(excelTitleWidth, () -> null);
}
public <T extends CmmnQuery> T setExcelTitleWidth(int[] excelTitleWidth) {
this.excelTitleWidth = excelTitleWidth;
return self();
}
public String getThisDay() {
return ifEmpty(thisDay, () -> null);
}

@ -12,9 +12,11 @@ import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.TextStyle;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -26,7 +28,11 @@ import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Font;
import cokr.xit.base.file.xls.XLSWriter;
import cokr.xit.base.file.xls.XLSWriter.Styler;
import cokr.xit.fims.sndb.service.bean.SndngBean;
import cokr.xit.foundation.data.DataObject;
@ -422,5 +428,50 @@ public class CmmnUtil {
return band6;
}
/** 2 .<br/>
* 1 , 2 .
* @param list1, list2
* @return list3
*/
public static List<?> mergeListByIndex(List<?> list1, List<?> list2) {
List list3 = new ArrayList<>();
for(int i=0; i < list1.size(); i++) {
list3.add(list1.get(i));
list3.add(list2.get(i));
}
return list3;
}
/** .<br/>
* @param widths , xlsxWriter
* @return
*/
public static List<Styler> makeHeadersByDiffrentWidths(List<Integer> widths, XLSWriter xlsxWriter){
List<Styler> result = new ArrayList<Styler>();
Map<Integer, Styler> headerWidthMap = new HashMap<>();
for(int i=0; i < widths.size(); i++) {
if(headerWidthMap.get(widths.get(i)) == null) {
headerWidthMap.put(
widths.get(i),
new XLSWriter.Styler()
.width(widths.get(i))
.foregroundColor(HSSFColor.HSSFColorPredefined.LIGHT_BLUE.getIndex())
.configure(styler -> {
Font font = xlsxWriter.workbook().createFont();
font.setColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex());
styler.font(font);
})
);
}
result.add(headerWidthMap.get(widths.get(i)));
}
return result;
}
}

@ -470,11 +470,26 @@ $(document).ready(function(){
$('#btnReset--${pageName}').on('click', () => $P.fnReset());
$('#btnSearch--${pageName}').on('click', () => $P.searchCrdnList());
$('#btnExcel--${pageName}').on('click', function(){
if(!$P.crdnControl.dataset.empty){
$P.crdnControl.download();
} else {
if($P.crdnControl.dataset.empty){
alert("조회된 자료가 없습니다.");
return;
}
var excelTitle = [];
var excelTitleWidth = [];
$("#crdnThead--${pageName} th").not(".dummy-th").not(":eq(0)").each(function(){
var title = $(this).text();
excelTitle.push(title);
var titleWidth = $(this).outerWidth();
titleWidth = Math.ceil(titleWidth/10);
excelTitleWidth.push(titleWidth);
});
$P.crdnControl.query.excelTitle = excelTitle.join(",");
$P.crdnControl.query.excelTitleWidth = excelTitleWidth.join(",");
//return;
$P.crdnControl.download();
});
fnMakeScrollableTable($("#table-responsive--${pageName}")[0], $P.scrollCrdnList);

Loading…
Cancel
Save