parent
6af54dd884
commit
5bbf88ac2a
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.common.core.utils.poi;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
|
|
@ -43,7 +44,40 @@ public class MultiSheetExcelExporter {
|
|||
}
|
||||
}
|
||||
|
||||
public void addHeaderRowAndTitle(Sheet sheet, List<String> headers,String title) {
|
||||
|
||||
// 创建一个样式对象用于标题行
|
||||
CellStyle titleStyle = workbook.createCellStyle();
|
||||
titleStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
|
||||
titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
Font titleFont = workbook.createFont();
|
||||
titleFont.setBold(true); // 设置字体加粗
|
||||
titleStyle.setFont(titleFont);
|
||||
// 设置水平居中对齐
|
||||
titleStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
// 添加标题行
|
||||
Row titleRow = sheet.createRow(currentRowNum++);
|
||||
Cell titleCell = titleRow.createCell(0);
|
||||
titleCell.setCellValue(title); // 标题内容
|
||||
titleCell.setCellStyle(titleStyle);
|
||||
// 如果需要合并单元格,可以使用下面的语句
|
||||
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headers.size() - 1));
|
||||
Row headerRow = sheet.createRow(currentRowNum++);
|
||||
for (int i = 0; i < headers.size(); i++) {
|
||||
Cell cell = headerRow.createCell(i);
|
||||
cell.setCellValue(headers.get(i));
|
||||
// 可以在这里设置标题行的样式
|
||||
cell.setCellStyle(titleStyle);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDataRows(Sheet sheet, List<Map<String, Object>> dataList, List<String> headers) {
|
||||
|
||||
// 创建一个样式对象
|
||||
CellStyle titleStyle = workbook.createCellStyle();
|
||||
// 设置水平居中对齐
|
||||
titleStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
|
||||
for (Map<String, Object> rowData : dataList) {
|
||||
Row row = sheet.createRow(currentRowNum++);
|
||||
for (int i = 0; i < headers.size(); i++) {
|
||||
|
|
@ -63,6 +97,7 @@ public class MultiSheetExcelExporter {
|
|||
cell.setCellValue(value.toString());
|
||||
}
|
||||
}
|
||||
cell.setCellStyle(titleStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.bonus.common.security.annotation.RequiresPermissions;
|
|||
import com.bonus.system.att.entity.*;
|
||||
import com.bonus.system.att.service.AttDetailByMonthService;
|
||||
import com.bonus.system.att.service.AttGroupService;
|
||||
import com.bonus.system.att.service.AttendanceDetailsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -71,24 +72,24 @@ public class AttDetailByMonthController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 考勤明细导出
|
||||
*/
|
||||
@Resource(name = "attendanceDetailsService")
|
||||
private AttendanceDetailsService attendanceDetailsService;
|
||||
@RequiresPermissions("att:detail:export")
|
||||
@GetMapping("/export")
|
||||
public void export(HttpServletResponse response, AttDetailByMonthBean bean) {
|
||||
// try{
|
||||
// List<AttDetailByMonthBean> list = attDetailByMonthService.selectAttDetailList(data);
|
||||
// ExcelUtil<AttDetailByMonthBean> util = new ExcelUtil<AttDetailByMonthBean>(AttDetailByMonthBean.class);
|
||||
// util.exportExcel(response, list, "月异常报表");
|
||||
// }catch (Exception e){
|
||||
// log.error(e.toString(),e);
|
||||
// }
|
||||
|
||||
try {
|
||||
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
|
||||
//将表格时间区间取出来做标题
|
||||
String title = bean.getAttCurrentMonth();
|
||||
List<AttDetailByMonthBean> attDayReportList = attDetailByMonthService.selectAttDetailList(bean);
|
||||
Sheet departmentSheet1 = exporter.createSheet("月异常报表详情");
|
||||
List<String> departmentHeaders1 = Arrays.asList("序号", "姓名", "所属部门", "考勤月", "应考勤天数", "正常打卡天数",
|
||||
"迟到天数", "早退天数", "矿工天数", "打卡地异常天数", "出入异常天数");
|
||||
exporter.addHeaderRow(departmentSheet1, departmentHeaders1);
|
||||
exporter.addHeaderRowAndTitle(departmentSheet1, departmentHeaders1, title);
|
||||
List<Map<String, Object>> departmentData1 = new ArrayList<>();
|
||||
for (int i = 0; i < attDayReportList.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
|
@ -117,6 +118,7 @@ public class AttDetailByMonthController extends BaseController {
|
|||
headers.put("7", "外出办事");
|
||||
headers.put("8", "出入异常");
|
||||
headers.put("9", "打卡地异常");
|
||||
headers.put("99", "工作外出");
|
||||
Map<String, String> attStatus = getStringStringMap();
|
||||
if (StringHelper.isNotEmpty(bean.getAttCurrentMonth())) {
|
||||
List<String> monthFirstAndLast = getMonthFirstAndLast(bean.getAttCurrentMonth());
|
||||
|
|
@ -125,27 +127,49 @@ public class AttDetailByMonthController extends BaseController {
|
|||
dayTable.setEndDate(monthFirstAndLast.get(1));
|
||||
headers.entrySet()
|
||||
.forEach(entry -> {
|
||||
dayTable.setAttStatis(Integer.parseInt(entry.getKey()));
|
||||
List<AttDetailBean> list = attDetailByMonthService.getDetailList(dayTable);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "姓名", "所属部门", "考勤日期", "上班打卡时间", "上班状态", "打卡地址", "下班打卡时间", "下班状态", "打卡地址");
|
||||
exporter.addHeaderRow(departmentSheet2, departmentHeaders2);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("姓名", list.get(i).getName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("考勤日期", list.get(i).getAttCurrent());
|
||||
map.put("上班打卡时间", list.get(i).getGoWorkTime());
|
||||
map.put("上班状态", attStatus.get(String.valueOf(list.get(i).getGoWorkStatus())));
|
||||
map.put("上班打卡地址", list.get(i).getOffWorkAddress());
|
||||
map.put("下班打卡时间", list.get(i).getOffWorkTime());
|
||||
map.put("下班状态", attStatus.get(String.valueOf(list.get(i).getOffWorkStatus())));
|
||||
map.put("下班打卡地址", list.get(i).getOffWorkAddress());
|
||||
departmentData2.add(map);
|
||||
if("99".equals(entry.getKey())){
|
||||
AttDataDetailsBean att = new AttDataDetailsBean();
|
||||
att.setAttCurrentMonth(bean.getAttCurrentMonth());
|
||||
List<AttDataDetailsBean> list = attendanceDetailsService.getOutCountList(att);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "考勤日期", "姓名", "所属部门", "打卡时间", "打卡地址");
|
||||
exporter.addHeaderRowAndTitle(departmentSheet2, departmentHeaders2, title);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("考勤日期", list.get(i).getAttCurrentDay());
|
||||
map.put("姓名", list.get(i).getUserName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("打卡时间", list.get(i).getAttCurrentTime());
|
||||
map.put("打卡地址", list.get(i).getAttAddress());
|
||||
departmentData2.add(map);
|
||||
departmentData2.add(map);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
}else {
|
||||
dayTable.setAttStatis(Integer.parseInt(entry.getKey()));
|
||||
List<AttDetailBean> list = attDetailByMonthService.getDetailList(dayTable);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "姓名", "所属部门", "考勤日期", "上班打卡时间", "上班状态", "打卡地址", "下班打卡时间", "下班状态", "打卡地址");
|
||||
exporter.addHeaderRowAndTitle(departmentSheet2, departmentHeaders2, title);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("姓名", list.get(i).getName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("考勤日期", list.get(i).getAttCurrent());
|
||||
map.put("上班打卡时间", list.get(i).getGoWorkTime());
|
||||
map.put("上班状态", attStatus.get(String.valueOf(list.get(i).getGoWorkStatus())));
|
||||
map.put("上班打卡地址", list.get(i).getOffWorkAddress());
|
||||
map.put("下班打卡时间", list.get(i).getOffWorkTime());
|
||||
map.put("下班状态", attStatus.get(String.valueOf(list.get(i).getOffWorkStatus())));
|
||||
map.put("下班打卡地址", list.get(i).getOffWorkAddress());
|
||||
departmentData2.add(map);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
});
|
||||
// 导出Excel文件
|
||||
exporter.exportToResponse(response, "月报表导出");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.system.att.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -19,6 +20,7 @@ public class AttDataDetailsBean {
|
|||
/**
|
||||
* 组织名称
|
||||
*/
|
||||
@Excel(name = "所属部门", width = 10.0,height = 20.0, orderNum = "1")
|
||||
private String orgName;
|
||||
|
||||
/**
|
||||
|
|
@ -29,6 +31,7 @@ public class AttDataDetailsBean {
|
|||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@Excel(name = "姓名", width = 10.0,height = 20.0, orderNum = "0")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
|
|
@ -49,14 +52,22 @@ public class AttDataDetailsBean {
|
|||
/**
|
||||
* 考勤日期
|
||||
*/
|
||||
@Excel(name = "考勤日期", width = 10.0,height = 20.0, orderNum = "2")
|
||||
private String attCurrentDay;
|
||||
|
||||
/**
|
||||
* 考勤月
|
||||
*/
|
||||
private String attCurrentMonth;
|
||||
/**
|
||||
* 打卡时间
|
||||
*/
|
||||
@Excel(name = "打卡时间", width = 10.0,height = 20.0, orderNum = "3")
|
||||
private String attCurrentTime;
|
||||
/**
|
||||
* 打卡地址
|
||||
*/
|
||||
@Excel(name = "打卡地址", width = 10.0,height = 20.0, orderNum = "4")
|
||||
private String attAddress;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -590,67 +590,6 @@ public class AttTasks {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理没有进出记录的考勤数据
|
||||
*
|
||||
* @param sourceDataNoInOutList
|
||||
* @return
|
||||
*/
|
||||
private List<AttSourceDataBean> threadNoInOutAttData(List<AttSourceDataBean> sourceDataNoInOutList) {
|
||||
List<AttSourceDataBean> list = new ArrayList<>();
|
||||
//分组排序
|
||||
Map<String, List<AttSourceDataBean>> groupedItems = sourceDataNoInOutList.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
c -> c.getName() + c.getAttCurrentDay(),
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.toList(),
|
||||
v -> {
|
||||
v.sort(Comparator.comparing(AttSourceDataBean::getAttCurrentTime));
|
||||
return v;
|
||||
}
|
||||
)
|
||||
));
|
||||
groupedItems.forEach((c, v) -> {
|
||||
//第二天早上5点前打的卡算前一天下班卡
|
||||
// AttSourceDataBean nextOffWork = getNextOffWorkDate(v);
|
||||
//第一次上班时间
|
||||
AttSourceDataBean frontToWorkBean = v.stream()
|
||||
.filter(a -> {
|
||||
String time = a.getAttCurrentTime();
|
||||
String startTime = DateUtils.getYyyyMmDd(a.getAttCurrentTime()) + " 05:00:00";
|
||||
String endTime = DateUtils.getYyyyMmDd(a.getAttCurrentTime()) + " 12:00:00";
|
||||
return DateUtils.getTimeIsRange(time, startTime, endTime);
|
||||
})
|
||||
.collect(Collectors.toList())
|
||||
.stream().min(Comparator.comparing(AttSourceDataBean::getAttCurrentTime)).orElse(null);
|
||||
|
||||
//最新一次下班时间
|
||||
AttSourceDataBean backOffWorkBean = v.stream()
|
||||
.filter(a -> {
|
||||
String time = a.getAttCurrentTime();
|
||||
String startTime = DateUtils.getYyyyMmDd(a.getAttCurrentTime()) + " 12:00:01";
|
||||
String endTime = DateUtils.getYyyyMmDd(a.getAttCurrentTime()) + " 23:59:59";
|
||||
return DateUtils.getTimeIsRange(time, startTime, endTime);
|
||||
})
|
||||
.collect(Collectors.toList())
|
||||
.stream().max(Comparator.comparing(AttSourceDataBean::getAttCurrentTime)).orElse(null);
|
||||
if (frontToWorkBean != null) {
|
||||
if (StringUtils.isNotEmpty(frontToWorkBean.getAttCurrentTime())) {
|
||||
frontToWorkBean.setAttType("1");
|
||||
list.add(frontToWorkBean);
|
||||
}
|
||||
}
|
||||
if (backOffWorkBean != null) {
|
||||
if (StringUtils.isNotEmpty(backOffWorkBean.getAttCurrentTime())) {
|
||||
backOffWorkBean.setAttType("2");
|
||||
list.add(backOffWorkBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 固定考勤数据计算
|
||||
*
|
||||
|
|
@ -1125,10 +1064,11 @@ public class AttTasks {
|
|||
}
|
||||
}
|
||||
|
||||
// 计算时间差
|
||||
// 减 1 原因:返回的是整数,如果是10.9,返回也是10,所以为了判断准确,减掉1
|
||||
long difference = (date2.getTime() - date1.getTime()) / 60000 - 1;
|
||||
|
||||
if ("1".equals(attType)) { // 上班打卡
|
||||
// 计算时间差
|
||||
// 减 1 原因:返回的是整数,如果是10.9,返回也是10,所以为了判断准确,减掉1
|
||||
long difference = (date2.getTime() - date1.getTime()) / 60000 - 1;
|
||||
if (difference > 0) {
|
||||
if (difference > absenteeismThreshold) {
|
||||
status = 3; // 旷工
|
||||
|
|
@ -1137,6 +1077,8 @@ public class AttTasks {
|
|||
}
|
||||
}
|
||||
} else if ("2".equals(attType)) { // 下班打卡
|
||||
// 计算时间差
|
||||
long difference = (date2.getTime() - date1.getTime()) / 60000;
|
||||
if (difference < 0) {
|
||||
if (Math.abs(difference) > lateThreshold) {
|
||||
status = 4; // 早退
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ import com.bonus.system.wechat.service.WechatEvectionService;
|
|||
import com.bonus.system.wechat.service.WechatLeaveReportingService;
|
||||
import com.bonus.system.wechat.service.WechatService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -412,27 +412,16 @@ public class ExportFileController {
|
|||
*/
|
||||
@GetMapping("/exportDayReport")
|
||||
public void exportDayReport(HttpServletResponse response, AttDayReportBean bean) {
|
||||
// try {
|
||||
// List<AttDayReportExportBean> personExportVoList = new ArrayList<>();
|
||||
// List<AttDayReportBean> attDayReportList = attendanceDetailsService.getAttDayReportList(bean);
|
||||
// for (int i = 0; i < attDayReportList.size(); i++) {
|
||||
// AttDayReportBean vo = attDayReportList.get(i);
|
||||
// AttDayReportExportBean voe = new AttDayReportExportBean();
|
||||
// BeanUtils.copyProperties(vo, voe);
|
||||
// voe.setId((i + 1));
|
||||
// personExportVoList.add(voe);
|
||||
// }
|
||||
// extracted(personExportVoList, AttDayReportExportBean.class, "日报表导出", "日报表导出", "日报表导出", response);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.toString(), e);
|
||||
// }
|
||||
try {
|
||||
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
|
||||
//将表格时间区间取出来做标题
|
||||
String title = bean.getStartDate() + "至" + bean.getEndDate();
|
||||
List<AttDayReportBean> attDayReportList = attendanceDetailsService.getAttDayReportList(bean);
|
||||
Sheet departmentSheet1 = exporter.createSheet("日报表详情");
|
||||
List<String> departmentHeaders1 = Arrays.asList("序号", "考勤日期", "正常打卡人数", "迟到人数", "早退人数",
|
||||
"矿工人数", "请假人数", "打卡地异常人数", "出入异常人数", "轮休人数", "临时外出人数");
|
||||
exporter.addHeaderRow(departmentSheet1, departmentHeaders1);
|
||||
|
||||
exporter.addHeaderRowAndTitle(departmentSheet1, departmentHeaders1, title);
|
||||
List<Map<String, Object>> departmentData1 = new ArrayList<>();
|
||||
for (int i = 0; i < attDayReportList.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
|
@ -461,6 +450,8 @@ public class ExportFileController {
|
|||
headers.put("7", "外出办事");
|
||||
headers.put("8", "出入异常");
|
||||
headers.put("9", "打卡地异常");
|
||||
//工作外出单独一个,序号不占用考勤状态
|
||||
headers.put("99", "工作外出");
|
||||
Map<String, String> attStatus = getStringStringMap();
|
||||
if (StringHelper.isNotEmpty(bean.getStartDate()) && StringHelper.isNotEmpty(bean.getEndDate())) {
|
||||
AttDataDetailsBean dayTable = new AttDataDetailsBean();
|
||||
|
|
@ -468,27 +459,49 @@ public class ExportFileController {
|
|||
dayTable.setEndDate(bean.getEndDate());
|
||||
headers.entrySet()
|
||||
.forEach(entry -> {
|
||||
dayTable.setAttStatus(entry.getKey());
|
||||
List<AttDataDetailsBean> list = attendanceDetailsService.getAttDayReportDetailsList(dayTable);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "姓名", "所属部门", "考勤日期", "上班打卡时间", "上班状态", "打卡地址", "下班打卡时间", "下班状态", "打卡地址");
|
||||
exporter.addHeaderRow(departmentSheet2, departmentHeaders2);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("姓名", list.get(i).getUserName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("考勤日期", list.get(i).getAttCurrentDay());
|
||||
map.put("上班打卡时间", list.get(i).getToWorkAttCurrentTime());
|
||||
map.put("上班状态", attStatus.get(list.get(i).getToWorkAttStatus()));
|
||||
map.put("上班打卡地址", list.get(i).getToWorkAttAddress());
|
||||
map.put("下班打卡时间", list.get(i).getOffWorkAttCurrentTime());
|
||||
map.put("下班状态", attStatus.get(list.get(i).getOffWorkAttStatus()));
|
||||
map.put("下班打卡地址", list.get(i).getOffWorkAttAddress());
|
||||
departmentData2.add(map);
|
||||
if("99".equals(entry.getKey())){
|
||||
List<AttDataDetailsBean> list = attendanceDetailsService.getOutCountList(dayTable);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "考勤日期", "姓名", "所属部门", "打卡时间", "打卡地址");
|
||||
exporter.addHeaderRowAndTitle(departmentSheet2, departmentHeaders2, title);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("考勤日期", list.get(i).getAttCurrentDay());
|
||||
map.put("姓名", list.get(i).getUserName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("打卡时间", list.get(i).getAttCurrentTime());
|
||||
map.put("打卡地址", list.get(i).getAttAddress());
|
||||
departmentData2.add(map);
|
||||
departmentData2.add(map);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
}else{
|
||||
dayTable.setAttStatus(entry.getKey());
|
||||
List<AttDataDetailsBean> list = attendanceDetailsService.getAttDayReportDetailsList(dayTable);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "姓名", "所属部门", "考勤日期", "上班打卡时间", "上班状态", "打卡地址", "下班打卡时间", "下班状态", "打卡地址");
|
||||
// exporter.addHeaderRow(departmentSheet2, departmentHeaders2);
|
||||
exporter.addHeaderRowAndTitle(departmentSheet2, departmentHeaders2, title);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("姓名", list.get(i).getUserName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("考勤日期", list.get(i).getAttCurrentDay());
|
||||
map.put("上班打卡时间", list.get(i).getToWorkAttCurrentTime());
|
||||
map.put("上班状态", attStatus.get(list.get(i).getToWorkAttStatus()));
|
||||
map.put("上班打卡地址", list.get(i).getToWorkAttAddress());
|
||||
map.put("下班打卡时间", list.get(i).getOffWorkAttCurrentTime());
|
||||
map.put("下班状态", attStatus.get(list.get(i).getOffWorkAttStatus()));
|
||||
map.put("下班打卡地址", list.get(i).getOffWorkAttAddress());
|
||||
departmentData2.add(map);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
});
|
||||
// 导出Excel文件
|
||||
exporter.exportToResponse(response, "日报表导出");
|
||||
|
|
@ -534,27 +547,15 @@ public class ExportFileController {
|
|||
*/
|
||||
@GetMapping("/exportMonthReport")
|
||||
public void exportMonthReport(HttpServletResponse response, AttMonthReportBean bean) {
|
||||
// try {
|
||||
// List<AttMonthReportExportBean> personExportVoList = new ArrayList<>();
|
||||
// List<AttMonthReportBean> attMonthReportList = attendanceDetailsService.getAttMonthReportList(bean);
|
||||
// for (int i = 0; i < attMonthReportList.size(); i++) {
|
||||
// AttMonthReportBean vo = attMonthReportList.get(i);
|
||||
// AttMonthReportExportBean voe = new AttMonthReportExportBean();
|
||||
// BeanUtils.copyProperties(vo, voe);
|
||||
// voe.setId(i + 1);
|
||||
// personExportVoList.add(voe);
|
||||
// }
|
||||
// extracted(personExportVoList, AttMonthReportExportBean.class, "月报表导出", "月报表导出", "月报表导出", response);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.toString(), e);
|
||||
// }
|
||||
try {
|
||||
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
|
||||
//将表格时间区间取出来做标题
|
||||
String title = bean.getMonth();
|
||||
List<AttMonthReportBean> attDayReportList = attendanceDetailsService.getAttMonthReportList(bean);
|
||||
Sheet departmentSheet1 = exporter.createSheet("月报表详情");
|
||||
List<String> departmentHeaders1 = Arrays.asList("序号", "姓名", "所属部门", "考勤月", "应考勤天数", "正常打卡天数",
|
||||
"迟到天数", "早退天数", "矿工天数", "请假天数", "打卡地异常天数", "出入异常天数", "轮休天数", "临时外出天数");
|
||||
exporter.addHeaderRow(departmentSheet1, departmentHeaders1);
|
||||
exporter.addHeaderRowAndTitle(departmentSheet1, departmentHeaders1, title);
|
||||
List<Map<String, Object>> departmentData1 = new ArrayList<>();
|
||||
for (int i = 0; i < attDayReportList.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
|
@ -586,6 +587,7 @@ public class ExportFileController {
|
|||
headers.put("7", "外出办事");
|
||||
headers.put("8", "出入异常");
|
||||
headers.put("9", "打卡地异常");
|
||||
headers.put("99", "工作外出");
|
||||
Map<String, String> attStatus = getStringStringMap();
|
||||
if (StringHelper.isNotEmpty(bean.getMonth())) {
|
||||
List<String> monthFirstAndLast = getMonthFirstAndLast(bean.getMonth());
|
||||
|
|
@ -594,28 +596,49 @@ public class ExportFileController {
|
|||
dayTable.setEndDate(monthFirstAndLast.get(1));
|
||||
headers.entrySet()
|
||||
.forEach(entry -> {
|
||||
dayTable.setAttStatis(Integer.parseInt(entry.getKey()));
|
||||
List<AttDetailBean> list = attDetailByMonthService.getDetailList(dayTable);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "姓名", "所属部门", "考勤日期", "上班打卡时间", "上班状态", "打卡地址", "下班打卡时间", "下班状态", "打卡地址");
|
||||
exporter.addHeaderRow(departmentSheet2, departmentHeaders2);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("姓名", list.get(i).getName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("考勤日期", list.get(i).getAttCurrent());
|
||||
map.put("上班打卡时间", list.get(i).getGoWorkTime());
|
||||
map.put("上班状态", attStatus.get(String.valueOf(list.get(i).getGoWorkStatus())));
|
||||
map.put("上班打卡地址", list.get(i).getOffWorkAddress());
|
||||
map.put("下班打卡时间", list.get(i).getOffWorkTime());
|
||||
map.put("下班状态", attStatus.get(String.valueOf(list.get(i).getOffWorkStatus())));
|
||||
map.put("下班打卡地址", list.get(i).getOffWorkAddress());
|
||||
departmentData2.add(map);
|
||||
if("99".equals(entry.getKey())){
|
||||
AttDataDetailsBean att = new AttDataDetailsBean();
|
||||
att.setAttCurrentMonth(bean.getMonth());
|
||||
List<AttDataDetailsBean> list = attendanceDetailsService.getOutCountList(att);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "考勤日期", "姓名", "所属部门", "打卡时间", "打卡地址");
|
||||
exporter.addHeaderRowAndTitle(departmentSheet2, departmentHeaders2, title);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("考勤日期", list.get(i).getAttCurrentDay());
|
||||
map.put("姓名", list.get(i).getUserName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("打卡时间", list.get(i).getAttCurrentTime());
|
||||
map.put("打卡地址", list.get(i).getAttAddress());
|
||||
departmentData2.add(map);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
}else {
|
||||
dayTable.setAttStatis(Integer.parseInt(entry.getKey()));
|
||||
List<AttDetailBean> list = attDetailByMonthService.getDetailList(dayTable);
|
||||
Sheet departmentSheet2 = exporter.createSheet(entry.getValue());
|
||||
List<String> departmentHeaders2 = Arrays.asList("序号", "姓名", "所属部门", "考勤日期", "上班打卡时间", "上班状态", "打卡地址", "下班打卡时间", "下班状态", "打卡地址");
|
||||
exporter.addHeaderRowAndTitle(departmentSheet2, departmentHeaders2, title);
|
||||
List<Map<String, Object>> departmentData2 = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("序号", i + 1);
|
||||
map.put("姓名", list.get(i).getName());
|
||||
map.put("所属部门", list.get(i).getOrgName());
|
||||
map.put("考勤日期", list.get(i).getAttCurrent());
|
||||
map.put("上班打卡时间", list.get(i).getGoWorkTime());
|
||||
map.put("上班状态", attStatus.get(String.valueOf(list.get(i).getGoWorkStatus())));
|
||||
map.put("上班打卡地址", list.get(i).getOffWorkAddress());
|
||||
map.put("下班打卡时间", list.get(i).getOffWorkTime());
|
||||
map.put("下班状态", attStatus.get(String.valueOf(list.get(i).getOffWorkStatus())));
|
||||
map.put("下班打卡地址", list.get(i).getOffWorkAddress());
|
||||
departmentData2.add(map);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
}
|
||||
exporter.addDataRows(departmentSheet2, departmentData2, departmentHeaders2);
|
||||
});
|
||||
});
|
||||
// 导出Excel文件
|
||||
exporter.exportToResponse(response, "月报表导出");
|
||||
}
|
||||
|
|
@ -988,4 +1011,27 @@ public class ExportFileController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 考勤明细二级页面工作外出导出
|
||||
*
|
||||
* @param response
|
||||
* @param bean
|
||||
* @return void
|
||||
* @author:fly
|
||||
* @date:2024-10-14-10:30
|
||||
*/
|
||||
// @RequiresPermissions("att:org:change:export")
|
||||
@GetMapping("/exportAttWorkOut")
|
||||
public void exportAttWorkOut(HttpServletResponse response, AttDataDetailsBean bean) {
|
||||
try {
|
||||
List<AttDataDetailsBean> list = attendanceDetailsService.getOutCountList(bean);
|
||||
extracted(list, AttDataDetailsBean.class, "外出导出记录导出", "外出导出记录导出", "外出导出记录导出", response);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,12 +215,18 @@
|
|||
<if test="attCurrentDay != null and attCurrentDay != ''">
|
||||
and awa.att_current_day = #{attCurrentDay}
|
||||
</if>
|
||||
<if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
|
||||
and awa.att_current_day between #{startDate} AND #{endDate}
|
||||
</if>
|
||||
<if test="userId != null and userId != ''">
|
||||
and awa.user_id = #{userId}
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
and locate(#{userName},awa.user_name)
|
||||
</if>
|
||||
<if test="attCurrentMonth != null and attCurrentMonth != ''">
|
||||
and locate(#{attCurrentMonth},awa.att_current_day)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY
|
||||
awa.att_current_day DESC
|
||||
|
|
|
|||
Loading…
Reference in New Issue