Commit 9be28960 by 谢春璐

fix

parent 2d0f5649
......@@ -8,6 +8,8 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
......@@ -43,24 +45,36 @@ public class ExcelWrite {
Sheet sheet = null;
if (null != template) {
try {
if (template.getName().contains(".")&&template.getName().substring(template.getName().lastIndexOf(".")+1, template.getName().length()).toLowerCase().equals("xls")) {
if (template.getName().contains(".") && template.getName()
.substring(template.getName().lastIndexOf(".") + 1, template.getName().length()).toLowerCase()
.equals("xls")) {
workbook = new HSSFWorkbook(new POIFSFileSystem(new FileInputStream(template)));
}else{
workbook=new XSSFWorkbook(new FileInputStream(template));
} else {
workbook = new XSSFWorkbook(new FileInputStream(template));
}
sheet = workbook.getSheetAt(0);
sheet.setColumnWidth(0, 3766);
} catch (Exception e) {
}
} else {
if (out.getName().contains(".")&&out.getName().substring(out.getName().lastIndexOf(".")+1, out.getName().length()).toLowerCase().equals("xls")) {
if (out.getName().contains(".") && out.getName()
.substring(out.getName().lastIndexOf(".") + 1, out.getName().length()).toLowerCase().equals("xls")) {
workbook = new HSSFWorkbook();
}else{
workbook=new XSSFWorkbook();
} else {
workbook = new XSSFWorkbook();
}
sheet = workbook.createSheet(sheetName);
}
if (null != data.getTitles() && data.getTitles().length > 0) {
Row titleRow = sheet.createRow(0);
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor((short) 13);
cellStyle.setFillPattern(CellStyle.ALIGN_JUSTIFY);
Font font = workbook.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 16);
cellStyle.setFont(font);
titleRow.setRowStyle(cellStyle);
for (int j = 0; j < data.getTitles().length; j++) {
Cell busiDataCell = titleRow.createCell(j);
busiDataCell.setCellValue(data.getTitles()[j]);
......
......@@ -245,10 +245,12 @@ public class FileServiceImpl implements FileService {
newWorkCheckList.add(w);
});
newWorkCheckList.sort(Comparator.comparing(WorkCheck::getDate));
staff.setWorkCheckList(newWorkCheckList);
newStaffList.add(staff);
});
newStaffList.sort(Comparator.comparing(Staff::getName));
return newStaffList;
}
......@@ -261,15 +263,18 @@ public class FileServiceImpl implements FileService {
titleList.add("姓名");
// 取打卡记录中最早日期和最晚日期为标题的开始日期和结束日期
String start = staffList.stream().min(Comparator.comparing(staff -> staff.getWorkCheckList().get(0).getDate()))
String start = staffList.stream().min(
Comparator.comparing(staff -> DateUtils.parseDate(staff.getWorkCheckList().stream()
.min(Comparator.comparing(w -> DateUtils.parseDate(w.getDate()).getTime())).get().getDate())
.getTime()))
.get()
.getWorkCheckList().get(0).getDate();
List<WorkCheck> workCheckList = staffList.stream()
.max(Comparator
.comparing(staff -> staff.getWorkCheckList().get(staff.getWorkCheckList().size() - 1).getDate()))
.get()
.getWorkCheckList();
List<WorkCheck> workCheckList = staffList.stream().max(
Comparator.comparing(staff -> DateUtils.parseDate(staff.getWorkCheckList().stream()
.max(Comparator.comparing(w -> DateUtils.parseDate(w.getDate()).getTime())).get().getDate())
.getTime()))
.get().getWorkCheckList();
String end = workCheckList.get(workCheckList.size() - 1).getDate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment